From 028b1c2ad15b0a01ce67fd7c142d2afcfd91da6d Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Tue, 6 Feb 2024 01:33:39 +0000 Subject: [PATCH 01/18] Move math PAL that redefined functions to handle boundary conditions consistently across platforms into a library in src/native that we can use across our libraries (or remove). --- src/coreclr/CMakeLists.txt | 5 + .../classlibnative/float/CMakeLists.txt | 3 +- .../classlibnative/float/floatdouble.cpp | 17 +- .../classlibnative/float/floatsingle.cpp | 17 +- src/coreclr/jit/CMakeLists.txt | 1 + src/coreclr/jit/jitpch.h | 1 + src/coreclr/jit/static/CMakeLists.txt | 1 + src/coreclr/jit/valuenum.cpp | 32 +- src/coreclr/pal/inc/pal.h | 18 - src/coreclr/pal/src/cruntime/math.cpp | 680 ------------------ src/coreclr/pal/src/include/pal/palinternal.h | 36 + src/coreclr/pal/tests/palsuite/CMakeLists.txt | 57 -- .../palsuite/c_runtime/abs/test1/abs.cpp | 53 -- .../palsuite/c_runtime/acos/test1/test1.cpp | 129 ---- .../palsuite/c_runtime/acosf/test1/test1.cpp | 128 ---- .../palsuite/c_runtime/acosh/test1/test1.cpp | 128 ---- .../palsuite/c_runtime/acoshf/test1/test1.cpp | 127 ---- .../palsuite/c_runtime/asin/test1/test1.cpp | 145 ---- .../palsuite/c_runtime/asinf/test1/test1.cpp | 144 ---- .../palsuite/c_runtime/asinh/test1/test1.cpp | 145 ---- .../palsuite/c_runtime/asinhf/test1/test1.cpp | 144 ---- .../palsuite/c_runtime/atan/test1/test1.cpp | 127 ---- .../palsuite/c_runtime/atan2/test1/test1.cpp | 147 ---- .../palsuite/c_runtime/atan2f/test1/test1.cpp | 146 ---- .../palsuite/c_runtime/atanf/test1/test1.cpp | 126 ---- .../palsuite/c_runtime/atanh/test1/test1.cpp | 129 ---- .../palsuite/c_runtime/atanhf/test1/test1.cpp | 128 ---- .../palsuite/c_runtime/cbrt/test1/test1.cpp | 122 ---- .../palsuite/c_runtime/cbrtf/test1/test1.cpp | 121 ---- .../palsuite/c_runtime/ceil/test1/test1.cpp | 131 ---- .../palsuite/c_runtime/ceilf/test1/test1.cpp | 130 ---- .../palsuite/c_runtime/cos/test1/test1.cpp | 130 ---- .../palsuite/c_runtime/cosf/test1/test1.cpp | 129 ---- .../palsuite/c_runtime/cosh/test1/test1.cpp | 129 ---- .../palsuite/c_runtime/coshf/test1/test1.cpp | 128 ---- .../palsuite/c_runtime/exp/test1/test1.cpp | 137 ---- .../palsuite/c_runtime/expf/test1/test1.cpp | 136 ---- .../palsuite/c_runtime/fabs/test1/test1.cpp | 129 ---- .../palsuite/c_runtime/fabsf/test1/test1.cpp | 129 ---- .../palsuite/c_runtime/floor/test1/test1.cpp | 131 ---- .../palsuite/c_runtime/floorf/test1/test1.cpp | 130 ---- .../palsuite/c_runtime/fma/test1/test1.cpp | 145 ---- .../palsuite/c_runtime/fmaf/test1/test1.cpp | 144 ---- .../palsuite/c_runtime/fmod/test1/test1.cpp | 156 ---- .../palsuite/c_runtime/fmodf/test1/test1.cpp | 155 ---- .../palsuite/c_runtime/ilogb/test1/test1.cpp | 100 --- .../palsuite/c_runtime/ilogbf/test1/test1.cpp | 100 --- .../palsuite/c_runtime/log/test1/test1.cpp | 139 ---- .../palsuite/c_runtime/log10/test1/test1.cpp | 145 ---- .../palsuite/c_runtime/log10f/test1/test1.cpp | 143 ---- .../palsuite/c_runtime/log2/test1/test1.cpp | 138 ---- .../palsuite/c_runtime/log2f/test1/test1.cpp | 137 ---- .../palsuite/c_runtime/logf/test1/test1.cpp | 138 ---- .../palsuite/c_runtime/modf/test1/test1.cpp | 135 ---- .../palsuite/c_runtime/modff/test1/test1.cpp | 134 ---- .../palsuite/c_runtime/pow/test1/test1.cpp | 229 ------ .../palsuite/c_runtime/powf/test1/test1.cpp | 228 ------ .../palsuite/c_runtime/sin/test1/test1.cpp | 130 ---- .../palsuite/c_runtime/sincos/test1/test1.cpp | 135 ---- .../c_runtime/sincosf/test1/test1.cpp | 134 ---- .../palsuite/c_runtime/sinf/test1/test1.cpp | 129 ---- .../palsuite/c_runtime/sinh/test1/test1.cpp | 129 ---- .../palsuite/c_runtime/sinhf/test1/test1.cpp | 128 ---- .../palsuite/c_runtime/sqrt/test1/test1.cpp | 122 ---- .../palsuite/c_runtime/sqrtf/test1/test1.cpp | 121 ---- .../palsuite/c_runtime/tan/test1/test1.cpp | 136 ---- .../palsuite/c_runtime/tanf/test1/test1.cpp | 135 ---- .../palsuite/c_runtime/tanh/test1/test1.cpp | 129 ---- .../palsuite/c_runtime/tanhf/test1/test1.cpp | 128 ---- .../pal/tests/palsuite/common/palsuite.h | 1 - .../pal/tests/palsuite/compilableTests.txt | 49 -- .../pal/tests/palsuite/paltestlist.txt | 52 -- .../corehost/apphost/static/CMakeLists.txt | 4 + src/native/netintrinsics/CMakeLists.txt | 8 + src/native/netintrinsics/config.h.in | 17 + src/native/netintrinsics/configure.cmake | 200 ++++++ src/native/netintrinsics/math.c | 515 +++++++++++++ src/native/netintrinsics/netintrinsics.h | 45 ++ 78 files changed, 870 insertions(+), 8569 deletions(-) delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/abs/test1/abs.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/acos/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/acosf/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/acosh/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/acoshf/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/asin/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/asinf/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/asinh/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/asinhf/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/atan/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/atan2/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/atan2f/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/atanf/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/atanh/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/atanhf/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/cbrt/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/cbrtf/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/ceil/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/ceilf/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/cos/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/cosf/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/cosh/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/coshf/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/exp/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/expf/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/fabs/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/fabsf/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/floor/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/floorf/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/fma/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/fmaf/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/fmod/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/fmodf/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/ilogb/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/ilogbf/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/log/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/log10/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/log10f/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/log2/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/log2f/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/logf/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/modf/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/modff/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/pow/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/powf/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/sin/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/sincos/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/sincosf/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/sinf/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/sinh/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/sinhf/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/sqrt/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/sqrtf/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/tan/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/tanf/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/tanh/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/tanhf/test1/test1.cpp create mode 100644 src/native/netintrinsics/CMakeLists.txt create mode 100644 src/native/netintrinsics/config.h.in create mode 100644 src/native/netintrinsics/configure.cmake create mode 100644 src/native/netintrinsics/math.c create mode 100644 src/native/netintrinsics/netintrinsics.h diff --git a/src/coreclr/CMakeLists.txt b/src/coreclr/CMakeLists.txt index 1c314d9bf624e0..1b7f01bc8e7648 100644 --- a/src/coreclr/CMakeLists.txt +++ b/src/coreclr/CMakeLists.txt @@ -79,6 +79,11 @@ if(NOT CLR_CROSS_COMPONENTS_BUILD) add_subdirectory(${CLR_SRC_NATIVE_DIR}/libs libs-native) endif(NOT CLR_CROSS_COMPONENTS_BUILD) +#------------------------------- +# Include shared native libraries +#------------------------------- +add_subdirectory(${CLR_SRC_NATIVE_DIR}/netintrinsics netintrinsics) + #----------------------------------------- # Add Projects # - project which require platform header not clr's diff --git a/src/coreclr/classlibnative/float/CMakeLists.txt b/src/coreclr/classlibnative/float/CMakeLists.txt index a3032c4887c4ba..fa31a13c420273 100644 --- a/src/coreclr/classlibnative/float/CMakeLists.txt +++ b/src/coreclr/classlibnative/float/CMakeLists.txt @@ -1,5 +1,3 @@ -set(CMAKE_INCLUDE_CURRENT_DIR ON) - include_directories("../inc") set(FLOAT_SOURCES @@ -8,4 +6,5 @@ set(FLOAT_SOURCES ) add_library_clr(comfloat_wks OBJECT ${FLOAT_SOURCES}) +target_link_libraries(comfloat_wks PRIVATE netintrinsics) add_dependencies(comfloat_wks eventing_headers) diff --git a/src/coreclr/classlibnative/float/floatdouble.cpp b/src/coreclr/classlibnative/float/floatdouble.cpp index d20b772eb2207c..282f85e5b16a12 100644 --- a/src/coreclr/classlibnative/float/floatdouble.cpp +++ b/src/coreclr/classlibnative/float/floatdouble.cpp @@ -5,6 +5,7 @@ // #include +#include "netintrinsics.h" #include "floatdouble.h" @@ -48,7 +49,7 @@ FCIMPL1_V(double, COMDouble::Acos, double x) FCALL_CONTRACT; - return acos(x); + return netintrinsics_acos(x); FCIMPLEND /*=====================================Acosh==================================== @@ -66,7 +67,7 @@ FCIMPLEND FCIMPL1_V(double, COMDouble::Asin, double x) FCALL_CONTRACT; - return asin(x); + return netintrinsics_asin(x); FCIMPLEND /*=====================================Asinh==================================== @@ -102,7 +103,7 @@ FCIMPLEND FCIMPL2_VV(double, COMDouble::Atan2, double y, double x) FCALL_CONTRACT; - return atan2(y, x); + return netintrinsics_atan2(y, x); FCIMPLEND /*====================================Cbrt====================================== @@ -158,7 +159,7 @@ FCIMPLEND FCIMPL1_V(double, COMDouble::Exp, double x) FCALL_CONTRACT; - return exp(x); + return netintrinsics_exp(x); FCIMPLEND #if defined(_MSC_VER) && defined(TARGET_X86) @@ -205,7 +206,7 @@ FCIMPLEND FCIMPL1_V(double, COMDouble::Log, double x) FCALL_CONTRACT; - return log(x); + return netintrinsics_log(x); FCIMPLEND /*=====================================Log2===================================== @@ -223,7 +224,7 @@ FCIMPLEND FCIMPL1_V(double, COMDouble::Log10, double x) FCALL_CONTRACT; - return log10(x); + return netintrinsics_log10(x); FCIMPLEND /*=====================================ModF===================================== @@ -241,7 +242,7 @@ FCIMPLEND FCIMPL2_VV(double, COMDouble::Pow, double x, double y) FCALL_CONTRACT; - return pow(x, y); + return netintrinsics_pow(x, y); FCIMPLEND /*=====================================Sin====================================== @@ -262,6 +263,8 @@ FCIMPL3_VII(void, COMDouble::SinCos, double x, double* pSin, double* pCos) #ifdef _MSC_VER *pSin = sin(x); *pCos = cos(x); +#elif defined(__APPLE__) + __sincos(x, pSin, pCos); #else sincos(x, pSin, pCos); #endif diff --git a/src/coreclr/classlibnative/float/floatsingle.cpp b/src/coreclr/classlibnative/float/floatsingle.cpp index 1694fd78cb8467..f74cf0f5550bb8 100644 --- a/src/coreclr/classlibnative/float/floatsingle.cpp +++ b/src/coreclr/classlibnative/float/floatsingle.cpp @@ -5,6 +5,7 @@ // #include +#include "netintrinsics.h" #include "floatsingle.h" @@ -34,7 +35,7 @@ FCIMPL1_V(float, COMSingle::Acos, float x) FCALL_CONTRACT; - return acosf(x); + return netintrinsics_acosf(x); FCIMPLEND /*=====================================Acosh==================================== @@ -52,7 +53,7 @@ FCIMPLEND FCIMPL1_V(float, COMSingle::Asin, float x) FCALL_CONTRACT; - return asinf(x); + return netintrinsics_asinf(x); FCIMPLEND /*=====================================Asinh==================================== @@ -88,7 +89,7 @@ FCIMPLEND FCIMPL2_VV(float, COMSingle::Atan2, float y, float x) FCALL_CONTRACT; - return atan2f(y, x); + return netintrinsics_atan2f(y, x); FCIMPLEND /*====================================Cbrt====================================== @@ -144,7 +145,7 @@ FCIMPLEND FCIMPL1_V(float, COMSingle::Exp, float x) FCALL_CONTRACT; - return expf(x); + return netintrinsics_expf(x); FCIMPLEND /*====================================Floor===================================== @@ -180,7 +181,7 @@ FCIMPLEND FCIMPL1_V(float, COMSingle::Log, float x) FCALL_CONTRACT; - return logf(x); + return netintrinsics_logf(x); FCIMPLEND /*=====================================Log2===================================== @@ -198,7 +199,7 @@ FCIMPLEND FCIMPL1_V(float, COMSingle::Log10, float x) FCALL_CONTRACT; - return log10f(x); + return netintrinsics_log10f(x); FCIMPLEND /*=====================================ModF===================================== @@ -216,7 +217,7 @@ FCIMPLEND FCIMPL2_VV(float, COMSingle::Pow, float x, float y) FCALL_CONTRACT; - return powf(x, y); + return netintrinsics_powf(x, y); FCIMPLEND /*=====================================Sin====================================== @@ -237,6 +238,8 @@ FCIMPL3_VII(void, COMSingle::SinCos, float x, float* pSin, float* pCos) #ifdef _MSC_VER *pSin = sinf(x); *pCos = cosf(x); +#elif defined(__APPLE__) + __sincosf(x, pSin, pCos); #else sincosf(x, pSin, pCos); #endif diff --git a/src/coreclr/jit/CMakeLists.txt b/src/coreclr/jit/CMakeLists.txt index 480d9d50350ddc..36395cc2d33670 100644 --- a/src/coreclr/jit/CMakeLists.txt +++ b/src/coreclr/jit/CMakeLists.txt @@ -523,6 +523,7 @@ add_custom_target(jit_exports DEPENDS ${JIT_EXPORTS_FILE}) set(JIT_LINK_LIBRARIES utilcodestaticnohost + netintrinsics ) set(JIT_ARCH_LINK_LIBRARIES diff --git a/src/coreclr/jit/jitpch.h b/src/coreclr/jit/jitpch.h index 63f12133f61bff..1d4d75de34fe5e 100644 --- a/src/coreclr/jit/jitpch.h +++ b/src/coreclr/jit/jitpch.h @@ -12,6 +12,7 @@ #include #include #include +#include "netintrinsics.h" // Don't allow using the windows.h #defines for the BitScan* APIs. Using the #defines means our // `BitOperations::BitScan*` functions have their name mapped, which is confusing and messes up diff --git a/src/coreclr/jit/static/CMakeLists.txt b/src/coreclr/jit/static/CMakeLists.txt index 89dd2bc72e8a89..27bf35f361c909 100644 --- a/src/coreclr/jit/static/CMakeLists.txt +++ b/src/coreclr/jit/static/CMakeLists.txt @@ -14,3 +14,4 @@ endif(CLR_CMAKE_HOST_UNIX) target_include_directories(clrjit_static PRIVATE ${JIT_SOURCE_DIR}) target_precompile_headers(clrjit_static PRIVATE [["jitpch.h"]]) +target_link_libraries(clrjit_static PRIVATE netintrinsics) diff --git a/src/coreclr/jit/valuenum.cpp b/src/coreclr/jit/valuenum.cpp index 744e13e099eaf9..77661938fb4c73 100644 --- a/src/coreclr/jit/valuenum.cpp +++ b/src/coreclr/jit/valuenum.cpp @@ -8266,7 +8266,7 @@ ValueNum ValueNumStore::EvalMathFuncUnary(var_types typ, NamedIntrinsic gtMathFN break; case NI_System_Math_Acos: - res = acos(arg0Val); + res = netintrinsics_acos(arg0Val); break; case NI_System_Math_Acosh: @@ -8274,7 +8274,7 @@ ValueNum ValueNumStore::EvalMathFuncUnary(var_types typ, NamedIntrinsic gtMathFN break; case NI_System_Math_Asin: - res = asin(arg0Val); + res = netintrinsics_asin(arg0Val); break; case NI_System_Math_Asinh: @@ -8306,7 +8306,7 @@ ValueNum ValueNumStore::EvalMathFuncUnary(var_types typ, NamedIntrinsic gtMathFN break; case NI_System_Math_Exp: - res = exp(arg0Val); + res = netintrinsics_exp(arg0Val); break; case NI_System_Math_Floor: @@ -8314,7 +8314,7 @@ ValueNum ValueNumStore::EvalMathFuncUnary(var_types typ, NamedIntrinsic gtMathFN break; case NI_System_Math_Log: - res = log(arg0Val); + res = netintrinsics_log(arg0Val); break; case NI_System_Math_Log2: @@ -8322,7 +8322,7 @@ ValueNum ValueNumStore::EvalMathFuncUnary(var_types typ, NamedIntrinsic gtMathFN break; case NI_System_Math_Log10: - res = log10(arg0Val); + res = netintrinsics_log10(arg0Val); break; case NI_System_Math_Sin: @@ -8374,7 +8374,7 @@ ValueNum ValueNumStore::EvalMathFuncUnary(var_types typ, NamedIntrinsic gtMathFN break; case NI_System_Math_Acos: - res = acosf(arg0Val); + res = netintrinsics_acosf(arg0Val); break; case NI_System_Math_Acosh: @@ -8382,7 +8382,7 @@ ValueNum ValueNumStore::EvalMathFuncUnary(var_types typ, NamedIntrinsic gtMathFN break; case NI_System_Math_Asin: - res = asinf(arg0Val); + res = netintrinsics_asinf(arg0Val); break; case NI_System_Math_Asinh: @@ -8414,7 +8414,7 @@ ValueNum ValueNumStore::EvalMathFuncUnary(var_types typ, NamedIntrinsic gtMathFN break; case NI_System_Math_Exp: - res = expf(arg0Val); + res = netintrinsics_expf(arg0Val); break; case NI_System_Math_Floor: @@ -8422,7 +8422,7 @@ ValueNum ValueNumStore::EvalMathFuncUnary(var_types typ, NamedIntrinsic gtMathFN break; case NI_System_Math_Log: - res = logf(arg0Val); + res = netintrinsics_logf(arg0Val); break; case NI_System_Math_Log2: @@ -8430,7 +8430,7 @@ ValueNum ValueNumStore::EvalMathFuncUnary(var_types typ, NamedIntrinsic gtMathFN break; case NI_System_Math_Log10: - res = log10f(arg0Val); + res = netintrinsics_log10f(arg0Val); break; case NI_System_Math_Sin: @@ -8480,14 +8480,14 @@ ValueNum ValueNumStore::EvalMathFuncUnary(var_types typ, NamedIntrinsic gtMathFN case TYP_DOUBLE: { double arg0Val = GetConstantDouble(arg0VN); - res = ilogb(arg0Val); + res = netintrinsics_ilogb(arg0Val); break; } case TYP_FLOAT: { float arg0Val = GetConstantSingle(arg0VN); - res = ilogbf(arg0Val); + res = netintrinsics_ilogbf(arg0Val); break; } @@ -8652,7 +8652,7 @@ ValueNum ValueNumStore::EvalMathFuncBinary(var_types typ, NamedIntrinsic gtMathF { assert(typ == TypeOfVN(arg1VN)); double arg1Val = GetConstantDouble(arg1VN); - res = atan2(arg0Val, arg1Val); + res = netintrinsics_atan2(arg0Val, arg1Val); break; } @@ -8668,7 +8668,7 @@ ValueNum ValueNumStore::EvalMathFuncBinary(var_types typ, NamedIntrinsic gtMathF { assert(typ == TypeOfVN(arg1VN)); double arg1Val = GetConstantDouble(arg1VN); - res = pow(arg0Val, arg1Val); + res = netintrinsics_pow(arg0Val, arg1Val); break; } @@ -8757,7 +8757,7 @@ ValueNum ValueNumStore::EvalMathFuncBinary(var_types typ, NamedIntrinsic gtMathF { assert(typ == TypeOfVN(arg1VN)); float arg1Val = GetConstantSingle(arg1VN); - res = atan2f(arg0Val, arg1Val); + res = netintrinsics_atan2f(arg0Val, arg1Val); break; } @@ -8837,7 +8837,7 @@ ValueNum ValueNumStore::EvalMathFuncBinary(var_types typ, NamedIntrinsic gtMathF { assert(typ == TypeOfVN(arg1VN)); float arg1Val = GetConstantSingle(arg1VN); - res = powf(arg0Val, arg1Val); + res = netintrinsics_powf(arg0Val, arg1Val); break; } diff --git a/src/coreclr/pal/inc/pal.h b/src/coreclr/pal/inc/pal.h index 7cfdf4d949968e..2e459981242a8b 100644 --- a/src/coreclr/pal/inc/pal.h +++ b/src/coreclr/pal/inc/pal.h @@ -4004,24 +4004,6 @@ PAL_GetCurrentThreadAffinitySet(SIZE_T size, UINT_PTR* data); #define fgetpos PAL_fgetpos #define fsetpos PAL_fsetpos #define setvbuf PAL_setvbuf -#define acos PAL_acos -#define asin PAL_asin -#define atan2 PAL_atan2 -#define exp PAL_exp -#define ilogb PAL_ilogb -#define log PAL_log -#define log10 PAL_log10 -#define pow PAL_pow -#define sincos PAL_sincos -#define acosf PAL_acosf -#define asinf PAL_asinf -#define atan2f PAL_atan2f -#define expf PAL_expf -#define ilogbf PAL_ilogbf -#define logf PAL_logf -#define log10f PAL_log10f -#define powf PAL_powf -#define sincosf PAL_sincosf #define malloc PAL_malloc #define free PAL_free #define _strdup PAL__strdup diff --git a/src/coreclr/pal/src/cruntime/math.cpp b/src/coreclr/pal/src/cruntime/math.cpp index 14243f43a79c24..94cf864c9235b0 100644 --- a/src/coreclr/pal/src/cruntime/math.cpp +++ b/src/coreclr/pal/src/cruntime/math.cpp @@ -110,349 +110,6 @@ double __cdecl _copysign(double x, double y) return ret; } -/*++ -Function: - acos - -See MSDN. ---*/ -PALIMPORT double __cdecl PAL_acos(double x) -{ - double ret; - PERF_ENTRY(acos); - ENTRY("acos (x=%f)\n", x); - -#if !HAVE_COMPATIBLE_ACOS - errno = 0; -#endif // HAVE_COMPATIBLE_ACOS - - ret = acos(x); - -#if !HAVE_COMPATIBLE_ACOS - if (errno == EDOM) - { - ret = PAL_NAN_DBL; // NaN - } -#endif // HAVE_COMPATIBLE_ACOS - - LOGEXIT("acos returns double %f\n", ret); - PERF_EXIT(acos); - return ret; -} - -/*++ -Function: - asin - -See MSDN. ---*/ -PALIMPORT double __cdecl PAL_asin(double x) -{ - double ret; - PERF_ENTRY(asin); - ENTRY("asin (x=%f)\n", x); - -#if !HAVE_COMPATIBLE_ASIN - errno = 0; -#endif // HAVE_COMPATIBLE_ASIN - - ret = asin(x); - -#if !HAVE_COMPATIBLE_ASIN - if (errno == EDOM) - { - ret = PAL_NAN_DBL; // NaN - } -#endif // HAVE_COMPATIBLE_ASIN - - LOGEXIT("asin returns double %f\n", ret); - PERF_EXIT(asin); - return ret; -} - -/*++ -Function: - atan2 - -See MSDN. ---*/ -PALIMPORT double __cdecl PAL_atan2(double y, double x) -{ - double ret; - PERF_ENTRY(atan2); - ENTRY("atan2 (y=%f, x=%f)\n", y, x); - -#if !HAVE_COMPATIBLE_ATAN2 - errno = 0; -#endif // !HAVE_COMPATIBLE_ATAN2 - - ret = atan2(y, x); - -#if !HAVE_COMPATIBLE_ATAN2 - if ((errno == EDOM) && (x == 0.0) && (y == 0.0)) - { - const double sign_x = copysign(1.0, x); - const double sign_y = copysign(1.0, y); - - if (sign_x > 0) - { - ret = copysign(0.0, sign_y); - } - else - { - ret = copysign(atan2(0.0, -1.0), sign_y); - } - } -#endif // !HAVE_COMPATIBLE_ATAN2 - - LOGEXIT("atan2 returns double %f\n", ret); - PERF_EXIT(atan2); - return ret; -} - -/*++ -Function: - exp - -See MSDN. ---*/ -PALIMPORT double __cdecl PAL_exp(double x) -{ - double ret; - PERF_ENTRY(exp); - ENTRY("exp (x=%f)\n", x); - -#if !HAVE_COMPATIBLE_EXP - if (x == 1.0) - { - ret = M_E; - } - else - { -#endif // HAVE_COMPATIBLE_EXP - - ret = exp(x); - -#if !HAVE_COMPATIBLE_EXP - } -#endif // HAVE_COMPATIBLE_EXP - - LOGEXIT("exp returns double %f\n", ret); - PERF_EXIT(exp); - return ret; -} - -/*++ -Function: - ilogb - -See MSDN. ---*/ -PALIMPORT int __cdecl PAL_ilogb(double x) -{ - int ret; - PERF_ENTRY(ilogb); - ENTRY("ilogb (x=%f)\n", x); - -#if !HAVE_COMPATIBLE_ILOGB0 - if (x == 0.0) - { - ret = -2147483648; - } - else -#endif // !HAVE_COMPATIBLE_ILOGB0 - -#if !HAVE_COMPATIBLE_ILOGBNAN - if (isnan(x)) - { - ret = 2147483647; - } - else -#endif // !HAVE_COMPATIBLE_ILOGBNAN - - { - ret = ilogb(x); - } - - LOGEXIT("ilogb returns int %d\n", ret); - PERF_EXIT(ilogb); - return ret; -} - -/*++ -Function: - log - -See MSDN. ---*/ -PALIMPORT double __cdecl PAL_log(double x) -{ - double ret; - PERF_ENTRY(log); - ENTRY("log (x=%f)\n", x); - -#if !HAVE_COMPATIBLE_LOG - errno = 0; -#endif // !HAVE_COMPATIBLE_LOG - - ret = log(x); - -#if !HAVE_COMPATIBLE_LOG - if ((errno == EDOM) && (x < 0)) - { - ret = PAL_NAN_DBL; // NaN - } -#endif // !HAVE_COMPATIBLE_LOG - - LOGEXIT("log returns double %f\n", ret); - PERF_EXIT(log); - return ret; -} - -/*++ -Function: - log10 - -See MSDN. ---*/ -PALIMPORT double __cdecl PAL_log10(double x) -{ - double ret; - PERF_ENTRY(log10); - ENTRY("log10 (x=%f)\n", x); - -#if !HAVE_COMPATIBLE_LOG10 - errno = 0; -#endif // !HAVE_COMPATIBLE_LOG10 - - ret = log10(x); - -#if !HAVE_COMPATIBLE_LOG10 - if ((errno == EDOM) && (x < 0)) - { - ret = PAL_NAN_DBL; // NaN - } -#endif // !HAVE_COMPATIBLE_LOG10 - - LOGEXIT("log10 returns double %f\n", ret); - PERF_EXIT(log10); - return ret; -} - -/*++ -Function: - pow - -See MSDN. ---*/ -PALIMPORT double __cdecl PAL_pow(double x, double y) -{ - double ret; - PERF_ENTRY(pow); - ENTRY("pow (x=%f, y=%f)\n", x, y); - -#if !HAVE_COMPATIBLE_POW - if ((y == PAL_POSINF_DBL) && !isnan(x)) // +Inf - { - if (x == 1.0) - { - ret = x; - } - else if (x == -1.0) - { - ret = 1.0; - } - else if ((x > -1.0) && (x < 1.0)) - { - ret = 0.0; - } - else - { - ret = PAL_POSINF_DBL; // +Inf - } - } - else if ((y == PAL_NEGINF_DBL) && !isnan(x)) // -Inf - { - if (x == 1.0) - { - ret = x; - } - else if (x == -1.0) - { - ret = 1.0; - } - else if ((x > -1.0) && (x < 1.0)) - { - ret = PAL_POSINF_DBL; // +Inf - } - else - { - ret = 0.0; - } - } - else if (IS_DBL_NEGZERO(x) && (y == -1.0)) - { - ret = PAL_NEGINF_DBL; // -Inf - } - else if ((x == 0.0) && (y < 0.0)) - { - ret = PAL_POSINF_DBL; // +Inf - } - else -#endif // !HAVE_COMPATIBLE_POW - - ret = pow(x, y); - -#if !HAVE_VALID_NEGATIVE_INF_POW - if ((ret == PAL_POSINF_DBL) && (x < 0) && isfinite(x) && (ceil(y / 2) != floor(y / 2))) - { - ret = PAL_NEGINF_DBL; // -Inf - } -#endif // !HAVE_VALID_NEGATIVE_INF_POW - -#if !HAVE_VALID_POSITIVE_INF_POW - /* - * The even/odd test in the if (this one and the one above) used to be ((long long) y % 2 == 0) - * on SPARC (long long) y for large y (>2**63) is always 0x7fffffff7fffffff, which - * is an odd number, so the test ((long long) y % 2 == 0) will always fail for - * large y. Since large double numbers are always even (e.g., the representation of - * 1E20+1 is the same as that of 1E20, the last .+1. is too insignificant to be part - * of the representation), this test will always return the wrong result for large y. - * - * The (ceil(y/2) == floor(y/2)) test is slower, but more robust. - */ - if ((ret == PAL_NEGINF_DBL) && (x < 0) && isfinite(x) && (ceil(y / 2) == floor(y / 2))) - { - ret = PAL_POSINF_DBL; // +Inf - } -#endif // !HAVE_VALID_POSITIVE_INF_POW - - LOGEXIT("pow returns double %f\n", ret); - PERF_EXIT(pow); - return ret; -} - -/*++ -Function: - sincos - -See MSDN. ---*/ -PALIMPORT void __cdecl PAL_sincos(double x, double* sin, double* cos) -{ - PERF_ENTRY(sincos); - ENTRY("sincos (x=%f)\n", x); - -#if defined(__APPLE__) - __sincos(x, sin, cos); -#else - sincos(x, sin, cos); -#endif // !__APPLE__ - - LOGEXIT("sincos returns (double %f, double %f)\n", *sin, *cos); - PERF_EXIT(sincos); -} - /*++ Function: _finitef @@ -520,340 +177,3 @@ float __cdecl _copysignf(float x, float y) PERF_EXIT(_copysignf); return ret; } - -/*++ -Function: - acosf - -See MSDN. ---*/ -PALIMPORT float __cdecl PAL_acosf(float x) -{ - float ret; - PERF_ENTRY(acosf); - ENTRY("acosf (x=%f)\n", x); - -#if !HAVE_COMPATIBLE_ACOS - errno = 0; -#endif // HAVE_COMPATIBLE_ACOS - - ret = acosf(x); - -#if !HAVE_COMPATIBLE_ACOS - if (errno == EDOM) - { - ret = PAL_NAN_FLT; // NaN - } -#endif // HAVE_COMPATIBLE_ACOS - - LOGEXIT("acosf returns float %f\n", ret); - PERF_EXIT(acosf); - return ret; -} - -/*++ -Function: - asinf - -See MSDN. ---*/ -PALIMPORT float __cdecl PAL_asinf(float x) -{ - float ret; - PERF_ENTRY(asinf); - ENTRY("asinf (x=%f)\n", x); - -#if !HAVE_COMPATIBLE_ASIN - errno = 0; -#endif // HAVE_COMPATIBLE_ASIN - - ret = asinf(x); - -#if !HAVE_COMPATIBLE_ASIN - if (errno == EDOM) - { - ret = PAL_NAN_FLT; // NaN - } -#endif // HAVE_COMPATIBLE_ASIN - - LOGEXIT("asinf returns float %f\n", ret); - PERF_EXIT(asinf); - return ret; -} - -/*++ -Function: - atan2f - -See MSDN. ---*/ -PALIMPORT float __cdecl PAL_atan2f(float y, float x) -{ - float ret; - PERF_ENTRY(atan2f); - ENTRY("atan2f (y=%f, x=%f)\n", y, x); - -#if !HAVE_COMPATIBLE_ATAN2 - errno = 0; -#endif // !HAVE_COMPATIBLE_ATAN2 - - ret = atan2f(y, x); - -#if !HAVE_COMPATIBLE_ATAN2 - if ((errno == EDOM) && (x == 0.0f) && (y == 0.0f)) - { - const float sign_x = copysign(1.0f, x); - const float sign_y = copysign(1.0f, y); - - if (sign_x > 0) - { - ret = copysign(0.0f, sign_y); - } - else - { - ret = copysign(atan2f(0.0f, -1.0f), sign_y); - } - } -#endif // !HAVE_COMPATIBLE_ATAN2 - - LOGEXIT("atan2f returns float %f\n", ret); - PERF_EXIT(atan2f); - return ret; -} - -/*++ -Function: - expf - -See MSDN. ---*/ -PALIMPORT float __cdecl PAL_expf(float x) -{ - float ret; - PERF_ENTRY(expf); - ENTRY("expf (x=%f)\n", x); - -#if !HAVE_COMPATIBLE_EXP - if (x == 1.0f) - { - ret = M_E; - } - else - { -#endif // HAVE_COMPATIBLE_EXP - - ret = expf(x); - -#if !HAVE_COMPATIBLE_EXP - } -#endif // HAVE_COMPATIBLE_EXP - - LOGEXIT("expf returns float %f\n", ret); - PERF_EXIT(expf); - return ret; -} - -/*++ -Function: - ilogbf - -See MSDN. ---*/ -PALIMPORT int __cdecl PAL_ilogbf(float x) -{ - int ret; - PERF_ENTRY(ilogbf); - ENTRY("ilogbf (x=%f)\n", x); - -#if !HAVE_COMPATIBLE_ILOGB0 - if (x == 0.0f) - { - ret = -2147483648; - } - else -#endif // !HAVE_COMPATIBLE_ILOGB0 - -#if !HAVE_COMPATIBLE_ILOGBNAN - if (isnan(x)) - { - ret = 2147483647; - } - else -#endif // !HAVE_COMPATIBLE_ILOGBNAN - - { - ret = ilogbf(x); - } - - LOGEXIT("ilogbf returns int %d\n", ret); - PERF_EXIT(ilogbf); - return ret; -} - -/*++ -Function: - logf - -See MSDN. ---*/ -PALIMPORT float __cdecl PAL_logf(float x) -{ - float ret; - PERF_ENTRY(logf); - ENTRY("logf (x=%f)\n", x); - -#if !HAVE_COMPATIBLE_LOG - errno = 0; -#endif // !HAVE_COMPATIBLE_LOG - - ret = logf(x); - -#if !HAVE_COMPATIBLE_LOG - if ((errno == EDOM) && (x < 0)) - { - ret = PAL_NAN_FLT; // NaN - } -#endif // !HAVE_COMPATIBLE_LOG - - LOGEXIT("logf returns float %f\n", ret); - PERF_EXIT(logf); - return ret; -} - -/*++ -Function: - log10f - -See MSDN. ---*/ -PALIMPORT float __cdecl PAL_log10f(float x) -{ - float ret; - PERF_ENTRY(log10f); - ENTRY("log10f (x=%f)\n", x); - -#if !HAVE_COMPATIBLE_LOG10 - errno = 0; -#endif // !HAVE_COMPATIBLE_LOG10 - - ret = log10f(x); - -#if !HAVE_COMPATIBLE_LOG10 - if ((errno == EDOM) && (x < 0)) - { - ret = PAL_NAN_FLT; // NaN - } -#endif // !HAVE_COMPATIBLE_LOG10 - - LOGEXIT("log10f returns float %f\n", ret); - PERF_EXIT(log10f); - return ret; -} - -/*++ -Function: - powf - -See MSDN. ---*/ -PALIMPORT float __cdecl PAL_powf(float x, float y) -{ - float ret; - PERF_ENTRY(powf); - ENTRY("powf (x=%f, y=%f)\n", x, y); - -#if !HAVE_COMPATIBLE_POW - if ((y == PAL_POSINF_FLT) && !isnan(x)) // +Inf - { - if (x == 1.0f) - { - ret = x; - } - else if (x == -1.0f) - { - ret = 1.0f; - } - else if ((x > -1.0f) && (x < 1.0f)) - { - ret = 0.0f; - } - else - { - ret = PAL_POSINF_FLT; // +Inf - } - } - else if ((y == PAL_NEGINF_FLT) && !isnan(x)) // -Inf - { - if (x == 1.0f) - { - ret = x; - } - else if (x == -1.0f) - { - ret = 1.0f; - } - else if ((x > -1.0f) && (x < 1.0f)) - { - ret = PAL_POSINF_FLT; // +Inf - } - else - { - ret = 0.0f; - } - } - else if (IS_FLT_NEGZERO(x) && (y == -1.0f)) - { - ret = PAL_NEGINF_FLT; // -Inf - } - else if ((x == 0.0f) && (y < 0.0f)) - { - ret = PAL_POSINF_FLT; // +Inf - } - else -#endif // !HAVE_COMPATIBLE_POW - - ret = powf(x, y); - -#if !HAVE_VALID_NEGATIVE_INF_POW - if ((ret == PAL_POSINF_FLT) && (x < 0) && isfinite(x) && (ceilf(y / 2) != floorf(y / 2))) - { - ret = PAL_NEGINF_FLT; // -Inf - } -#endif // !HAVE_VALID_NEGATIVE_INF_POW - -#if !HAVE_VALID_POSITIVE_INF_POW - /* - * The (ceil(y/2) == floor(y/2)) test is slower, but more robust for platforms where large y - * will return the wrong result for ((long) y % 2 == 0). See PAL_pow(double) above for more details. - */ - if ((ret == PAL_NEGINF_FLT) && (x < 0) && isfinite(x) && (ceilf(y / 2) == floorf(y / 2))) - { - ret = PAL_POSINF_FLT; // +Inf - } -#endif // !HAVE_VALID_POSITIVE_INF_POW - - LOGEXIT("powf returns float %f\n", ret); - PERF_EXIT(powf); - return ret; -} - -/*++ -Function: - sincosf - -See MSDN. ---*/ -PALIMPORT void __cdecl PAL_sincosf(float x, float* sin, float* cos) -{ - PERF_ENTRY(sincosf); - ENTRY("sincosf (x=%f)\n", x); - -#if defined(__APPLE__) - __sincosf(x, sin, cos); -#else - sincosf(x, sin, cos); -#endif // !__APPLE__ - - LOGEXIT("sincosf returns (float %f, float %f)\n", *sin, *cos); - PERF_EXIT(sincosf); -} diff --git a/src/coreclr/pal/src/include/pal/palinternal.h b/src/coreclr/pal/src/include/pal/palinternal.h index 63e6d305d9f6e7..a143b065e1177b 100644 --- a/src/coreclr/pal/src/include/pal/palinternal.h +++ b/src/coreclr/pal/src/include/pal/palinternal.h @@ -229,6 +229,24 @@ function_name() to call the system's implementation #define tanf DUMMY_tanf #define tanhf DUMMY_tanhf #define truncf DUMMY_truncf +#define acos DUMMMY_acos +#define asin DUMMMY_asin +#define atan2 DUMMMY_atan2 +#define exp DUMMMY_exp +#define ilogb DUMMMY_ilogb +#define log DUMMMY_log +#define log10 DUMMMY_log10 +#define pow DUMMMY_pow +#define sincos DUMMMY_sincos +#define acosf DUMMMY_acosf +#define asinf DUMMMY_asinf +#define atan2f DUMMMY_atan2f +#define expf DUMMMY_expf +#define ilogbf DUMMMY_ilogbf +#define logf DUMMMY_logf +#define log10f DUMMMY_log10f +#define powf DUMMMY_powf +#define sincosf DUMMMY_sincosf #define remove DUMMY_remove #define printf DUMMY_printf #define vprintf DUMMY_vprintf @@ -490,6 +508,24 @@ function_name() to call the system's implementation #undef tanf #undef tanhf #undef truncf +#undef acos +#undef asin +#undef atan2 +#undef exp +#undef ilogb +#undef log +#undef log10 +#undef pow +#undef sincos +#undef acosf +#undef asinf +#undef atan2f +#undef expf +#undef ilogbf +#undef logf +#undef log10f +#undef powf +#undef sincosf #undef rand #undef srand #undef errno diff --git a/src/coreclr/pal/tests/palsuite/CMakeLists.txt b/src/coreclr/pal/tests/palsuite/CMakeLists.txt index ee5a58f608ec88..63ba70e4a2d05d 100644 --- a/src/coreclr/pal/tests/palsuite/CMakeLists.txt +++ b/src/coreclr/pal/tests/palsuite/CMakeLists.txt @@ -63,53 +63,20 @@ add_executable_clr(paltests #composite/threading/threadsuspension_switchthread/threadsuspension.cpp #composite/wfmo/main.cpp #composite/wfmo/mutex.cpp - c_runtime/abs/test1/abs.cpp - c_runtime/acos/test1/test1.cpp - c_runtime/acosf/test1/test1.cpp - c_runtime/acosh/test1/test1.cpp - c_runtime/acoshf/test1/test1.cpp - c_runtime/asin/test1/test1.cpp - c_runtime/asinf/test1/test1.cpp - c_runtime/asinh/test1/test1.cpp - c_runtime/asinhf/test1/test1.cpp - c_runtime/atan/test1/test1.cpp - c_runtime/atan2/test1/test1.cpp - c_runtime/atan2f/test1/test1.cpp - c_runtime/atanf/test1/test1.cpp - c_runtime/atanh/test1/test1.cpp - c_runtime/atanhf/test1/test1.cpp c_runtime/atof/test1/test1.cpp c_runtime/atoi/test1/test1.cpp c_runtime/bsearch/test1/test1.cpp c_runtime/bsearch/test2/test2.cpp - c_runtime/cbrt/test1/test1.cpp - c_runtime/cbrtf/test1/test1.cpp - c_runtime/ceil/test1/test1.cpp - c_runtime/ceilf/test1/test1.cpp - c_runtime/cos/test1/test1.cpp - c_runtime/cosf/test1/test1.cpp - c_runtime/cosh/test1/test1.cpp - c_runtime/coshf/test1/test1.cpp c_runtime/errno/test1/test1.cpp c_runtime/errno/test2/test2.cpp c_runtime/exit/test1/test1.cpp c_runtime/exit/test2/test2.cpp - c_runtime/exp/test1/test1.cpp - c_runtime/expf/test1/test1.cpp - c_runtime/fabs/test1/test1.cpp - c_runtime/fabsf/test1/test1.cpp c_runtime/ferror/test1/test1.cpp c_runtime/ferror/test2/test2.cpp c_runtime/fflush/test1/test1.cpp c_runtime/fgets/test1/test1.cpp c_runtime/fgets/test2/test2.cpp c_runtime/fgets/test3/test3.cpp - c_runtime/floor/test1/test1.cpp - c_runtime/floorf/test1/test1.cpp - c_runtime/fma/test1/test1.cpp - c_runtime/fmaf/test1/test1.cpp - c_runtime/fmod/test1/test1.cpp - c_runtime/fmodf/test1/test1.cpp c_runtime/fopen/test1/test1.cpp c_runtime/fopen/test2/test2.cpp c_runtime/fopen/test3/test3.cpp @@ -126,8 +93,6 @@ add_executable_clr(paltests c_runtime/fseek/test1/test1.cpp c_runtime/ftell/test1/ftell.cpp c_runtime/fwrite/test1/test1.cpp - c_runtime/ilogb/test1/test1.cpp - c_runtime/ilogbf/test1/test1.cpp c_runtime/isalnum/test1/test1.cpp c_runtime/isalpha/test1/test1.cpp c_runtime/isdigit/test1/test1.cpp @@ -140,34 +105,16 @@ add_executable_clr(paltests c_runtime/iswupper/test1/test1.cpp c_runtime/isxdigit/test1/test1.cpp c_runtime/llabs/test1/test1.cpp - c_runtime/log/test1/test1.cpp - c_runtime/log10/test1/test1.cpp - c_runtime/log10f/test1/test1.cpp - c_runtime/log2/test1/test1.cpp - c_runtime/log2f/test1/test1.cpp - c_runtime/logf/test1/test1.cpp c_runtime/malloc/test1/test1.cpp c_runtime/malloc/test2/test2.cpp c_runtime/memchr/test1/test1.cpp c_runtime/memcmp/test1/test1.cpp c_runtime/memmove/test1/test1.cpp c_runtime/memset/test1/test1.cpp - c_runtime/modf/test1/test1.cpp - c_runtime/modff/test1/test1.cpp - c_runtime/pow/test1/test1.cpp - c_runtime/powf/test1/test1.cpp c_runtime/qsort/test1/test1.cpp c_runtime/qsort/test2/test2.cpp c_runtime/rand_srand/test1/test1.cpp c_runtime/realloc/test1/test1.cpp - c_runtime/sin/test1/test1.cpp - c_runtime/sincos/test1/test1.cpp - c_runtime/sincosf/test1/test1.cpp - c_runtime/sinf/test1/test1.cpp - c_runtime/sinh/test1/test1.cpp - c_runtime/sinhf/test1/test1.cpp - c_runtime/sqrt/test1/test1.cpp - c_runtime/sqrtf/test1/test1.cpp c_runtime/sscanf_s/test1/test1.cpp c_runtime/sscanf_s/test10/test10.cpp c_runtime/sscanf_s/test11/test11.cpp @@ -200,10 +147,6 @@ add_executable_clr(paltests c_runtime/strtod/test2/test2.cpp c_runtime/strtok/test1/test1.cpp c_runtime/strtoul/test1/test1.cpp - c_runtime/tan/test1/test1.cpp - c_runtime/tanf/test1/test1.cpp - c_runtime/tanh/test1/test1.cpp - c_runtime/tanhf/test1/test1.cpp c_runtime/time/test1/test1.cpp c_runtime/tolower/test1/test1.cpp c_runtime/toupper/test1/test1.cpp diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/abs/test1/abs.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/abs/test1/abs.cpp deleted file mode 100644 index 9ad83d64e3a73d..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/abs/test1/abs.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*===================================================================== -** -** Source: abs.c (test 1) -** -** Purpose: Tests the PAL implementation of the abs function. -** -** -**===================================================================*/ - -#include - -struct TESTS -{ - int nTest; - int nResult; -}; - -PALTEST(c_runtime_abs_test1_paltest_abs_test1, "c_runtime/abs/test1/paltest_abs_test1") -{ - int i = 0; - int nRc = 0; - struct TESTS testCase[] = - { - {0, 0}, - {1, 1}, - {-1, 1} - }; - - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - for (i = 0; i < (sizeof(testCase)/sizeof(struct TESTS)); i++) - { - nRc = abs(testCase[i].nTest); - if (nRc != testCase[i].nResult) - { - Fail("abs: ERROR -> abs(%d) returned %d " - "when it was expected to return %d \n", - testCase[i].nTest, - nRc, - testCase[i].nResult); - } - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/acos/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/acos/test1/test1.cpp deleted file mode 100644 index 5de46458e50515..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/acos/test1/test1.cpp +++ /dev/null @@ -1,129 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that acos return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabs -** -**===========================================================================*/ - -#include - -// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (15-17 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use -// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx -// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will -// use PAL_EPSILON * 10. -#define PAL_EPSILON 8.8817841970012523e-16 - -#define PAL_NAN sqrt(-1.0) -#define PAL_POSINF -log(0.0) -#define PAL_NEGINF log(0.0) - -/** - * Helper test structure - */ -struct test -{ - double value; /* value to test the function with */ - double expected; /* expected result */ - double variance; /* maximum delta between the expected and actual result */ -}; - -/** - * acos_test1_validate - * - * test validation function - */ -void __cdecl acos_test1_validate(double value, double expected, double variance) -{ - double result = acos(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - double delta = fabs(result - expected); - - if (delta > variance) - { - Fail("acos(%g) returned %20.17g when it should have returned %20.17g", - value, result, expected); - } -} - -/** - * acos_test1_validate - * - * test validation function for values returning NaN - */ -void __cdecl acos_test1_validate_isnan(double value) -{ - double result = acos(value); - - if (!_isnan(result)) - { - Fail("acos(%g) returned %20.17g when it should have returned %20.17g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -PALTEST(c_runtime_acos_test1_paltest_acos_test1, "c_runtime/acos/test1/paltest_acos_test1") -{ - struct test tests[] = - { - /* value expected variance */ - { -1, 3.1415926535897932, PAL_EPSILON * 10 }, // expected: pi - { -0.91173391478696510, 2.7182818284590452, PAL_EPSILON * 10 }, // expected: e - { -0.66820151019031295, 2.3025850929940457, PAL_EPSILON * 10 }, // expected: ln(10) - { 0, 1.5707963267948966, PAL_EPSILON * 10 }, // expected: pi / 2 - { 0.12775121753523991, 1.4426950408889634, PAL_EPSILON * 10 }, // expected: log2(e) - { 0.15594369476537447, 1.4142135623730950, PAL_EPSILON * 10 }, // expected: sqrt(2) - { 0.42812514788535792, 1.1283791670955126, PAL_EPSILON * 10 }, // expected: 2 / sqrt(pi) - { 0.54030230586813972, 1, PAL_EPSILON * 10 }, - { 0.70710678118654752, 0.78539816339744831, PAL_EPSILON }, // expected: pi / 4, value: 1 / sqrt(2) - { 0.76024459707563015, 0.70710678118654752, PAL_EPSILON }, // expected: 1 / sqrt(2) - { 0.76923890136397213, 0.69314718055994531, PAL_EPSILON }, // expected: ln(2) - { 0.80410982822879171, 0.63661977236758134, PAL_EPSILON }, // expected: 2 / pi - { 0.90716712923909839, 0.43429448190325183, PAL_EPSILON }, // expected: log10(e) - { 0.94976571538163866, 0.31830988618379067, PAL_EPSILON }, // expected: 1 / pi - { 1, 0, PAL_EPSILON }, - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - acos_test1_validate(tests[i].value, tests[i].expected, tests[i].variance); - } - - acos_test1_validate_isnan(PAL_NEGINF); - acos_test1_validate_isnan(PAL_NAN); - acos_test1_validate_isnan(PAL_POSINF); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/acosf/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/acosf/test1/test1.cpp deleted file mode 100644 index 909d43cab78a98..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/acosf/test1/test1.cpp +++ /dev/null @@ -1,128 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that acosf return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabs -** -**===========================================================================*/ - -#include - -// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (6-9 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON -// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use -// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10. -#define PAL_EPSILON 4.76837158e-07 - -#define PAL_NAN sqrtf(-1.0f) -#define PAL_POSINF -logf(0.0f) -#define PAL_NEGINF logf(0.0f) - -/** - * Helper test structure - */ -struct test -{ - float value; /* value to test the function with */ - float expected; /* expected result */ - float variance; /* maximum delta between the expected and actual result */ -}; - -/** - * acosf_test1_validate - * - * test validation function - */ -void __cdecl acosf_test1_validate(float value, float expected, float variance) -{ - float result = acosf(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - float delta = fabsf(result - expected); - - if (delta > variance) - { - Fail("acosf(%g) returned %10.9g when it should have returned %10.9g", - value, result, expected); - } -} - -/** - * acosf_test1_validate - * - * test validation function for values returning NaN - */ -void __cdecl acosf_test1_validate_isnan(float value) -{ - float result = acosf(value); - - if (!_isnanf(result)) - { - Fail("acosf(%g) returned %10.9g when it should have returned %10.9g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -PALTEST(c_runtime_acosf_test1_paltest_acosf_test1, "c_runtime/acosf/test1/paltest_acosf_test1") -{ - struct test tests[] = - { - /* value expected variance */ - { -1, 3.14159265f, PAL_EPSILON * 10 }, // expected: pi - { -0.911733915f, 2.71828183f, PAL_EPSILON * 10 }, // expected: e - { -0.668201510f, 2.30258509f, PAL_EPSILON * 10 }, // expected: ln(10) - { 0, 1.57079633f, PAL_EPSILON * 10 }, // expected: pi / 2 - { 0.127751218f, 1.44269504f, PAL_EPSILON * 10 }, // expected: logf2(e) - { 0.155943695f, 1.41421356f, PAL_EPSILON * 10 }, // expected: sqrtf(2) - { 0.428125148f, 1.12837917f, PAL_EPSILON * 10 }, // expected: 2 / sqrtf(pi) - { 0.540302306f, 1, PAL_EPSILON * 10 }, - { 0.707106781f, 0.785398163f, PAL_EPSILON }, // expected: pi / 4, value: 1 / sqrtf(2) - { 0.760244597f, 0.707106781f, PAL_EPSILON }, // expected: 1 / sqrtf(2) - { 0.769238901f, 0.693147181f, PAL_EPSILON }, // expected: ln(2) - { 0.804109828f, 0.636619772f, PAL_EPSILON }, // expected: 2 / pi - { 0.907167129f, 0.434294482f, PAL_EPSILON }, // expected: logf10f(e) - { 0.949765715f, 0.318309886f, PAL_EPSILON }, // expected: 1 / pi - { 1, 0, PAL_EPSILON }, - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - acosf_test1_validate(tests[i].value, tests[i].expected, tests[i].variance); - } - - acosf_test1_validate_isnan(PAL_NEGINF); - acosf_test1_validate_isnan(PAL_NAN); - acosf_test1_validate_isnan(PAL_POSINF); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/acosh/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/acosh/test1/test1.cpp deleted file mode 100644 index 3d9368fcd94f7b..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/acosh/test1/test1.cpp +++ /dev/null @@ -1,128 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that acosh return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabs -** -**===========================================================================*/ - -#include - -// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (15-17 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use -// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx -// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will -// use PAL_EPSILON * 10. -#define PAL_EPSILON 8.8817841970012523e-16 - -#define PAL_NAN sqrt(-1.0) -#define PAL_POSINF -log(0.0) -#define PAL_NEGINF log(0.0) - -/** - * Helper test structure - */ -struct test -{ - double value; /* value to test the function with */ - double expected; /* expected result */ - double variance; /* maximum delta between the expected and actual result */ -}; - -/** - * acosh_test1_validate - * - * test validation function - */ -void __cdecl acosh_test1_validate(double value, double expected, double variance) -{ - double result = acosh(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - double delta = fabs(result - expected); - - if (delta > variance) - { - Fail("acosh(%g) returned %20.17g when it should have returned %20.17g", - value, result, expected); - } -} - -/** - * acosh_test1_validate - * - * test validation function for values returning NaN - */ -void __cdecl acosh_test1_validate_isnan(double value) -{ - double result = acosh(value); - - if (!_isnan(result)) - { - Fail("acosh(%g) returned %20.17g when it should have returned %20.17g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -PALTEST(c_runtime_acosh_test1_paltest_acosh_test1, "c_runtime/acosh/test1/paltest_acosh_test1") -{ - struct test tests[] = - { - /* value expected variance */ - { 1, 0, PAL_EPSILON }, - { 1.0510897883672876, 0.31830988618379067, PAL_EPSILON }, // expected: 1 / pi - { 1.0957974645564909, 0.43429448190325183, PAL_EPSILON }, // expected: log10(e) - { 1.2095794864199787, 0.63661977236758134, PAL_EPSILON }, // expected: 2 / pi - { 1.25, 0.69314718055994531, PAL_EPSILON }, // expected: ln(2) - { 1.2605918365213561, 0.70710678118654752, PAL_EPSILON }, // expected: 1 / sqrt(2) - { 1.3246090892520058, 0.78539816339744831, PAL_EPSILON }, // expected: pi / 4 - { 1.5430806348152438, 1, PAL_EPSILON * 10 }, - { 1.7071001431069344, 1.1283791670955126, PAL_EPSILON * 10 }, // expected: 2 / sqrt(pi) - { 2.1781835566085709, 1.4142135623730950, PAL_EPSILON * 10 }, // expected: sqrt(2) - { 2.2341880974508023, 1.4426950408889634, PAL_EPSILON * 10 }, // expected: log2(e) - { 2.5091784786580568, 1.5707963267948966, PAL_EPSILON * 10 }, // expected: pi / 2 - { 5.05, 2.3025850929940457, PAL_EPSILON * 10 }, // expected: ln(10) - { 7.6101251386622884, 2.7182818284590452, PAL_EPSILON * 10 }, // expected: e - { 11.591953275521521, 3.1415926535897932, PAL_EPSILON * 10 }, // expected: pi - { PAL_POSINF, PAL_POSINF, 0 }, - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - acosh_test1_validate(tests[i].value, tests[i].expected, tests[i].variance); - } - - acosh_test1_validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/acoshf/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/acoshf/test1/test1.cpp deleted file mode 100644 index 78bab37dbf37d0..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/acoshf/test1/test1.cpp +++ /dev/null @@ -1,127 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that acoshf return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabs -** -**===========================================================================*/ - -#include - -// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (6-9 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON -// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use -// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10. -#define PAL_EPSILON 4.76837158e-07 - -#define PAL_NAN sqrtf(-1.0f) -#define PAL_POSINF -logf(0.0f) -#define PAL_NEGINF logf(0.0f) - -/** - * Helper test structure - */ -struct test -{ - float value; /* value to test the function with */ - float expected; /* expected result */ - float variance; /* maximum delta between the expected and actual result */ -}; - -/** - * acoshf_test1_validate - * - * test validation function - */ -void __cdecl acoshf_test1_validate(float value, float expected, float variance) -{ - float result = acoshf(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - float delta = fabsf(result - expected); - - if (delta > variance) - { - Fail("acoshf(%g) returned %10.9g when it should have returned %10.9g", - value, result, expected); - } -} - -/** - * acoshf_test1_validate - * - * test validation function for values returning NaN - */ -void __cdecl acoshf_test1_validate_isnan(float value) -{ - float result = acoshf(value); - - if (!_isnanf(result)) - { - Fail("acoshf(%g) returned %10.9g when it should have returned %10.9g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -PALTEST(c_runtime_acoshf_test1_paltest_acoshf_test1, "c_runtime/acoshf/test1/paltest_acoshf_test1") -{ - struct test tests[] = - { - /* value expected variance */ - { 1, 0, PAL_EPSILON }, - { 1.05108979f, 0.318309886f, PAL_EPSILON }, // expected: 1 / pi - { 1.09579746f, 0.434294482f, PAL_EPSILON }, // expected: log10f(e) - { 1.20957949f, 0.636619772f, PAL_EPSILON }, // expected: 2 / pi - { 1.25f, 0.693147181f, PAL_EPSILON }, // expected: ln(2) - { 1.26059184f, 0.707106781f, PAL_EPSILON }, // expected: 1 / sqrtf(2) - { 1.32460909f, 0.785398163f, PAL_EPSILON }, // expected: pi / 4 - { 1.54308063f, 1, PAL_EPSILON * 10 }, - { 1.70710014f, 1.12837917f, PAL_EPSILON * 10 }, // expected: 2 / sqrtf(pi) - { 2.17818356f, 1.41421356f, PAL_EPSILON * 10 }, // expected: sqrtf(2) - { 2.23418810f, 1.44269504f, PAL_EPSILON * 10 }, // expected: logf2(e) - { 2.50917848f, 1.57079633f, PAL_EPSILON * 10 }, // expected: pi / 2 - { 5.05f, 2.30258509f, PAL_EPSILON * 10 }, // expected: ln(10) - { 7.61012514f, 2.71828183f, PAL_EPSILON * 10 }, // expected: e - { 11.5919533f, 3.14159265f, PAL_EPSILON * 100 }, // expected: pi - { PAL_POSINF, PAL_POSINF, 0 }, - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - acoshf_test1_validate(tests[i].value, tests[i].expected, tests[i].variance); - } - - acoshf_test1_validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/asin/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/asin/test1/test1.cpp deleted file mode 100644 index b72599ad33d35a..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/asin/test1/test1.cpp +++ /dev/null @@ -1,145 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that asin return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabs -** -**===========================================================================*/ - -#include - -// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (15-17 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use -// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx -// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will -// use PAL_EPSILON * 10. -#define PAL_EPSILON 8.8817841970012523e-16 - -#define PAL_NAN sqrt(-1.0) -#define PAL_POSINF -log(0.0) -#define PAL_NEGINF log(0.0) - -/** - * Helper test structure - */ -struct test -{ - double value; /* value to test the function with */ - double expected; /* expected result */ - double variance; /* maximum delta between the expected and actual result */ -}; - -/** - * asin_test1_validate - * - * test validation function - */ -void __cdecl asin_test1_validate(double value, double expected, double variance) -{ - double result = asin(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - double delta = fabs(result - expected); - - if (delta > variance) - { - Fail("asin(%g) returned %20.17g when it should have returned %20.17g", - value, result, expected); - } -} - -/** - * asin_test1_validate - * - * test validation function for values returning NaN - */ -void __cdecl asin_test1_validate_isnan(double value) -{ - double result = asin(value); - - if (!_isnan(result)) - { - Fail("asin(%g) returned %20.17g when it should have returned %20.17g", - value, result, PAL_NAN); - } -} - -/** - * asin_test1_validate - * - * test validation function for values returning +INF - */ -void __cdecl asin_test1_validate_isinf_positive(double value) -{ - double result = asin(value); - - if (result != PAL_POSINF) - { - Fail("asin(%g) returned %20.17g when it should have returned %20.17g", - value, result, PAL_POSINF); - } -} - -/** - * main - * - * executable entry point - */ -PALTEST(c_runtime_asin_test1_paltest_asin_test1, "c_runtime/asin/test1/paltest_asin_test1") -{ - struct test tests[] = - { - /* value expected variance */ - { 0, 0, PAL_EPSILON }, - { 0.31296179620778659, 0.31830988618379067, PAL_EPSILON }, // expected: 1 / pi - { 0.41078129050290870, 0.42331082513074800, PAL_EPSILON }, // expected: pi - e - { 0.42077048331375735, 0.43429448190325183, PAL_EPSILON }, // expected: log10(e) - { 0.59448076852482208, 0.63661977236758134, PAL_EPSILON }, // expected: 2 / pi - { 0.63896127631363480, 0.69314718055994531, PAL_EPSILON }, // expected: ln(2) - { 0.64963693908006244, 0.70710678118654752, PAL_EPSILON }, // expected: 1 / sqrt(2) - { 0.70710678118654752, 0.78539816339744831, PAL_EPSILON }, // expected: pi / 4, value: 1 / sqrt(2) - { 0.74398033695749319, 0.83900756059574755, PAL_EPSILON }, // expected: pi - ln(10) - { 0.84147098480789651, 1, PAL_EPSILON * 10 }, - { 0.90371945743584630, 1.1283791670955126, PAL_EPSILON * 10 }, // expected: 2 / sqrt(pi) - { 0.98776594599273553, 1.4142135623730950, PAL_EPSILON * 10 }, // expected: sqrt(2) - { 0.99180624439366372, 1.4426950408889634, PAL_EPSILON * 10 }, // expected: log2(e) - { 1, 1.5707963267948966, PAL_EPSILON * 10 }, // expected: pi / 2 - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - asin_test1_validate( tests[i].value, tests[i].expected, tests[i].variance); - asin_test1_validate(-tests[i].value, -tests[i].expected, tests[i].variance); - } - - asin_test1_validate_isnan(PAL_NEGINF); - asin_test1_validate_isnan(PAL_NAN); - asin_test1_validate_isnan(PAL_POSINF); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/asinf/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/asinf/test1/test1.cpp deleted file mode 100644 index abf35c2618519f..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/asinf/test1/test1.cpp +++ /dev/null @@ -1,144 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that asinf return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabs -** -**===========================================================================*/ - -#include - -// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (6-9 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON -// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use -// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10. -#define PAL_EPSILON 4.76837158e-07 - -#define PAL_NAN sqrtf(-1.0f) -#define PAL_POSINF -logf(0.0f) -#define PAL_NEGINF logf(0.0f) - -/** - * Helper test structure - */ -struct test -{ - float value; /* value to test the function with */ - float expected; /* expected result */ - float variance; /* maximum delta between the expected and actual result */ -}; - -/** - * asinf_test1_validate - * - * test validation function - */ -void __cdecl asinf_test1_validate(float value, float expected, float variance) -{ - float result = asinf(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - float delta = fabsf(result - expected); - - if (delta > variance) - { - Fail("asinf(%g) returned %10.9g when it should have returned %10.9g", - value, result, expected); - } -} - -/** - * asinf_test1_validate - * - * test validation function for values returning NaN - */ -void __cdecl asinf_test1_validate_isnan(float value) -{ - float result = asinf(value); - - if (!_isnanf(result)) - { - Fail("asinf(%g) returned %10.9g when it should have returned %10.9g", - value, result, PAL_NAN); - } -} - -/** - * asinf_test1_validate - * - * test validation function for values returning +INF - */ -void __cdecl asinf_test1_validate_isinf_positive(float value) -{ - float result = asinf(value); - - if (result != PAL_POSINF) - { - Fail("asinf(%g) returned %10.9g when it should have returned %10.9g", - value, result, PAL_POSINF); - } -} - -/** - * main - * - * executable entry point - */ -PALTEST(c_runtime_asinf_test1_paltest_asinf_test1, "c_runtime/asinf/test1/paltest_asinf_test1") -{ - struct test tests[] = - { - /* value expected variance */ - { 0, 0, PAL_EPSILON }, - { 0.312961796f, 0.318309886f, PAL_EPSILON }, // expected: 1 / pi - { 0.410781291f, 0.423310825f, PAL_EPSILON }, // expected: pi - e - { 0.420770483f, 0.434294482f, PAL_EPSILON }, // expected: logf10f(e) - { 0.594480769f, 0.636619772f, PAL_EPSILON }, // expected: 2 / pi - { 0.638961276f, 0.693147181f, PAL_EPSILON }, // expected: ln(2) - { 0.649636939f, 0.707106781f, PAL_EPSILON }, // expected: 1 / sqrtf(2) - { 0.707106781f, 0.785398163f, PAL_EPSILON }, // expected: pi / 4, value: 1 / sqrtf(2) - { 0.743980337f, 0.839007561f, PAL_EPSILON }, // expected: pi - ln(10) - { 0.841470985f, 1, PAL_EPSILON * 10 }, - { 0.903719457f, 1.12837917f, PAL_EPSILON * 10 }, // expected: 2 / sqrtf(pi) - { 0.987765946f, 1.41421356f, PAL_EPSILON * 10 }, // expected: sqrtf(2) - { 0.991806244f, 1.44269504f, PAL_EPSILON * 10 }, // expected: logf2(e) - { 1, 1.57079633f, PAL_EPSILON * 10 }, // expected: pi / 2 - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - asinf_test1_validate( tests[i].value, tests[i].expected, tests[i].variance); - asinf_test1_validate(-tests[i].value, -tests[i].expected, tests[i].variance); - } - - asinf_test1_validate_isnan(PAL_NEGINF); - asinf_test1_validate_isnan(PAL_NAN); - asinf_test1_validate_isnan(PAL_POSINF); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/asinh/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/asinh/test1/test1.cpp deleted file mode 100644 index a0ed7953d2edfc..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/asinh/test1/test1.cpp +++ /dev/null @@ -1,145 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that asinh return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabs -** -**===========================================================================*/ - -#include - -// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (15-17 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use -// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx -// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will -// use PAL_EPSILON * 10. -#define PAL_EPSILON 8.8817841970012523e-16 - -#define PAL_NAN sqrt(-1.0) -#define PAL_POSINF -log(0.0) -#define PAL_NEGINF log(0.0) - -/** - * Helper test structure - */ -struct test -{ - double value; /* value to test the function with */ - double expected; /* expected result */ - double variance; /* maximum delta between the expected and actual result */ -}; - -/** - * asinh_test1_validate - * - * test validation function - */ -void __cdecl asinh_test1_validate(double value, double expected, double variance) -{ - double result = asinh(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - double delta = fabs(result - expected); - - if (delta > variance) - { - Fail("asinh(%g) returned %20.17g when it should have returned %20.17g", - value, result, expected); - } -} - -/** - * asinh_test1_validate - * - * test validation function for values returning NaN - */ -void __cdecl asinh_test1_validate_isnan(double value) -{ - double result = asinh(value); - - if (!_isnan(result)) - { - Fail("asinh(%g) returned %20.17g when it should have returned %20.17g", - value, result, PAL_NAN); - } -} - -/** - * asinh_test1_validate - * - * test validation function for values returning +INF - */ -void __cdecl asinh_test1_validate_isinf_positive(double value) -{ - double result = asinh(value); - - if (result != PAL_POSINF) - { - Fail("asinh(%g) returned %20.17g when it should have returned %20.17g", - value, result, PAL_POSINF); - } -} - -/** - * main - * - * executable entry point - */ -PALTEST(c_runtime_asinh_test1_paltest_asinh_test1, "c_runtime/asinh/test1/paltest_asinh_test1") -{ - struct test tests[] = - { - /* value expected variance */ - { 0, 0, PAL_EPSILON }, - { 0.32371243907207108, 0.31830988618379067, PAL_EPSILON }, // expected: 1 / pi - { 0.44807597941469025, 0.43429448190325183, PAL_EPSILON }, // expected: log10(e) - { 0.68050167815224332, 0.63661977236758134, PAL_EPSILON }, // expected: 2 / pi - { 0.75, 0.69314718055994531, PAL_EPSILON }, // expected: ln(2) - { 0.76752314512611633, 0.70710678118654752, PAL_EPSILON }, // expected: 1 / sqrt(2) - { 0.86867096148600961, 0.78539816339744831, PAL_EPSILON }, // expected: pi / 4 - { 1.1752011936438015, 1, PAL_EPSILON * 10 }, - { 1.3835428792038633, 1.1283791670955126, PAL_EPSILON * 10 }, // expected: 2 / sqrt(pi) - { 1.9350668221743567, 1.4142135623730950, PAL_EPSILON * 10 }, // expected: sqrt(2) - { 1.9978980091062796, 1.4426950408889634, PAL_EPSILON * 10 }, // expected: log2(e) - { 2.3012989023072949, 1.5707963267948966, PAL_EPSILON * 10 }, // expected: pi / 2 - { 4.95, 2.3025850929940457, PAL_EPSILON * 10 }, // expected: ln(10) - { 7.5441371028169758, 2.7182818284590452, PAL_EPSILON * 10 }, // expected: e - { 11.548739357257748, 3.1415926535897932, PAL_EPSILON * 10 }, // expected: pi - { PAL_POSINF, PAL_POSINF, 0 }, - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - asinh_test1_validate( tests[i].value, tests[i].expected, tests[i].variance); - asinh_test1_validate(-tests[i].value, -tests[i].expected, tests[i].variance); - } - - asinh_test1_validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/asinhf/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/asinhf/test1/test1.cpp deleted file mode 100644 index eb2af42b98c7c1..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/asinhf/test1/test1.cpp +++ /dev/null @@ -1,144 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that asinhf return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabs -** -**===========================================================================*/ - -#include - -// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (6-9 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON -// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use -// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10. -#define PAL_EPSILON 4.76837158e-07 - -#define PAL_NAN sqrtf(-1.0f) -#define PAL_POSINF -logf(0.0f) -#define PAL_NEGINF logf(0.0f) - -/** - * Helper test structure - */ -struct test -{ - float value; /* value to test the function with */ - float expected; /* expected result */ - float variance; /* maximum delta between the expected and actual result */ -}; - -/** - * asinhf_test1_validate - * - * test validation function - */ -void __cdecl asinhf_test1_validate(float value, float expected, float variance) -{ - float result = asinhf(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - float delta = fabsf(result - expected); - - if (delta > variance) - { - Fail("asinhf(%g) returned %10.9g when it should have returned %10.9g", - value, result, expected); - } -} - -/** - * asinhf_test1_validate - * - * test validation function for values returning NaN - */ -void __cdecl asinhf_test1_validate_isnan(float value) -{ - float result = asinhf(value); - - if (!_isnanf(result)) - { - Fail("asinhf(%g) returned %10.9g when it should have returned %10.9g", - value, result, PAL_NAN); - } -} - -/** - * asinhf_test1_validate - * - * test validation function for values returning +INF - */ -void __cdecl asinhf_test1_validate_isinf_positive(float value) -{ - float result = asinhf(value); - - if (result != PAL_POSINF) - { - Fail("asinhf(%g) returned %10.9g when it should have returned %10.9g", - value, result, PAL_POSINF); - } -} - -/** - * main - * - * executable entry point - */ -PALTEST(c_runtime_asinhf_test1_paltest_asinhf_test1, "c_runtime/asinhf/test1/paltest_asinhf_test1") -{ - struct test tests[] = - { - /* value expected variance */ - { 0, 0, PAL_EPSILON }, - { 0.323712439f, 0.318309886f, PAL_EPSILON }, // expected: 1 / pi - { 0.448075979f, 0.434294482f, PAL_EPSILON }, // expected: log10f(e) - { 0.680501678f, 0.636619772f, PAL_EPSILON }, // expected: 2 / pi - { 0.75, 0.693147181f, PAL_EPSILON }, // expected: ln(2) - { 0.767523145f, 0.707106781f, PAL_EPSILON }, // expected: 1 / sqrtf(2) - { 0.868670961f, 0.785398163f, PAL_EPSILON }, // expected: pi / 4 - { 1.17520119f, 1, PAL_EPSILON * 10 }, - { 1.38354288f, 1.12837917f, PAL_EPSILON * 10 }, // expected: 2 / sqrtf(pi) - { 1.93506682f, 1.41421356f, PAL_EPSILON * 10 }, // expected: sqrtf(2) - { 1.99789801f, 1.44269504f, PAL_EPSILON * 10 }, // expected: logf2(e) - { 2.30129890f, 1.57079633f, PAL_EPSILON * 10 }, // expected: pi / 2 - { 4.95f, 2.30258509f, PAL_EPSILON * 10 }, // expected: ln(10) - { 7.54413710f, 2.71828183f, PAL_EPSILON * 10 }, // expected: e - { 11.5487394f, 3.14159265f, PAL_EPSILON * 10 }, // expected: pi - { PAL_POSINF, PAL_POSINF, 0 }, - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - asinhf_test1_validate( tests[i].value, tests[i].expected, tests[i].variance); - asinhf_test1_validate(-tests[i].value, -tests[i].expected, tests[i].variance); - } - - asinhf_test1_validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/atan/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/atan/test1/test1.cpp deleted file mode 100644 index 0e65933bc894f3..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/atan/test1/test1.cpp +++ /dev/null @@ -1,127 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that atan return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabs -** -**===========================================================================*/ - -#include - -// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (15-17 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use -// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx -// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will -// use PAL_EPSILON * 10. -#define PAL_EPSILON 8.8817841970012523e-16 - -#define PAL_NAN sqrt(-1.0) -#define PAL_POSINF -log(0.0) -#define PAL_NEGINF log(0.0) - -/** - * Helper test structure - */ -struct test -{ - double value; /* value to test the function with */ - double expected; /* expected result */ - double variance; /* maximum delta between the expected and actual result */ -}; - -/** - * atan_test1_validate - * - * test validation function - */ -void __cdecl atan_test1_validate(double value, double expected, double variance) -{ - double result = atan(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - double delta = fabs(result - expected); - - if (delta > variance) - { - Fail("atan(%g) returned %20.17g when it should have returned %20.17g", - value, result, expected); - } -} - -/** - * atan_test1_validate - * - * test validation function for values returning NaN - */ -void __cdecl atan_test1_validate_isnan(double value) -{ - double result = atan(value); - - if (!_isnan(result)) - { - Fail("atan(%g) returned %20.17g when it should have returned %20.17g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -PALTEST(c_runtime_atan_test1_paltest_atan_test1, "c_runtime/atan/test1/paltest_atan_test1") -{ - struct test tests[] = - { - /* value expected variance */ - { 0, 0, PAL_EPSILON }, - { 0.32951473309607836, 0.31830988618379067, PAL_EPSILON }, // expected: 1 / pi - { 0.45054953406980750, 0.42331082513074800, PAL_EPSILON }, // expected: pi - e - { 0.46382906716062964, 0.43429448190325183, PAL_EPSILON }, // expected: log10(e) - { 0.73930295048660405, 0.63661977236758134, PAL_EPSILON }, // expected: 2 / pi - { 0.83064087786078395, 0.69314718055994531, PAL_EPSILON }, // expected: ln(2) - { 0.85451043200960189, 0.70710678118654752, PAL_EPSILON }, // expected: 1 / sqrt(2) - { 1, 0.78539816339744831, PAL_EPSILON }, // expected: pi / 4 - { 1.1134071468135374, 0.83900756059574755, PAL_EPSILON }, // expected: pi - ln(10) - { 1.5574077246549022, 1, PAL_EPSILON * 10 }, - { 2.1108768356626451, 1.1283791670955126, PAL_EPSILON * 10 }, // expected: 2 / sqrt(pi) - { 6.3341191670421916, 1.4142135623730950, PAL_EPSILON * 10 }, // expected: sqrt(2) - { 7.7635756709721848, 1.4426950408889634, PAL_EPSILON * 10 }, // expected: log2(e) - { PAL_POSINF, 1.5707963267948966, PAL_EPSILON * 10 }, // expected: pi / 2 - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - atan_test1_validate( tests[i].value, tests[i].expected, tests[i].variance); - atan_test1_validate(-tests[i].value, -tests[i].expected, tests[i].variance); - } - - atan_test1_validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/atan2/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/atan2/test1/test1.cpp deleted file mode 100644 index 6298487994d5dc..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/atan2/test1/test1.cpp +++ /dev/null @@ -1,147 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Tests that atan2 returns correct values for a subset of values. -** Tests with positive and negative values of x and y to ensure -** atan2 is returning results from the correct quadrant. -** -**===================================================================*/ - -#include - -// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (15-17 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use -// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx -// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will -// use PAL_EPSILON * 10. -#define PAL_EPSILON 8.8817841970012523e-16 - -#define PAL_NAN sqrt(-1.0) -#define PAL_POSINF -log(0.0) -#define PAL_NEGINF log(0.0) - -struct test -{ - double y; /* second component of the value to test the function with */ - double x; /* first component of the value to test the function with */ - double expected; /* expected result */ - double variance; /* maximum delta between the expected and actual result */ -}; - -/** - * atan2_test1_validate - * - * test validation function - */ -void __cdecl atan2_test1_validate(double y, double x, double expected, double variance) -{ - double result = atan2(y, x); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - double delta = fabs(result - expected); - - if (delta > variance) - { - Fail("atan2(%g, %g) returned %20.17g when it should have returned %20.17g", - y, x, result, expected); - } -} - -/** - * atan2_test1_validate - * - * test validation function for values returning NaN - */ -void __cdecl atan2_test1_validate_isnan(double y, double x) -{ - double result = atan2(y, x); - - if (!_isnan(result)) - { - Fail("atan2(%g, %g) returned %20.17g when it should have returned %20.17g", - y, x, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -PALTEST(c_runtime_atan2_test1_paltest_atan2_test1, "c_runtime/atan2/test1/paltest_atan2_test1") -{ - struct test tests[] = - { - /* y x expected variance */ - { 0, PAL_POSINF, 0, PAL_EPSILON }, - { 0, 0, 0, PAL_EPSILON }, - { 0.31296179620778659, 0.94976571538163866, 0.31830988618379067, PAL_EPSILON }, // expected: 1 / pi - { 0.42077048331375735, 0.90716712923909839, 0.43429448190325183, PAL_EPSILON }, // expected: log10(e) - { 0.59448076852482208, 0.80410982822879171, 0.63661977236758134, PAL_EPSILON }, // expected: 2 / pi - { 0.63896127631363480, 0.76923890136397213, 0.69314718055994531, PAL_EPSILON }, // expected: ln(2) - { 0.64963693908006244, 0.76024459707563015, 0.70710678118654752, PAL_EPSILON }, // expected: 1 / sqrt(2) - { 0.70710678118654752, 0.70710678118654752, 0.78539816339744831, PAL_EPSILON }, // expected: pi / 4, value: 1 / sqrt(2) - { 1, 1, 0.78539816339744831, PAL_EPSILON }, // expected: pi / 4 - { PAL_POSINF, PAL_POSINF, 0.78539816339744831, PAL_EPSILON }, // expected: pi / 4 - { 0.84147098480789651, 0.54030230586813972, 1, PAL_EPSILON * 10 }, - { 0.90371945743584630, 0.42812514788535792, 1.1283791670955126, PAL_EPSILON * 10 }, // expected: 2 / sqrt(pi) - { 0.98776594599273553, 0.15594369476537447, 1.4142135623730950, PAL_EPSILON * 10 }, // expected: sqrt(2) - { 0.99180624439366372, 0.12775121753523991, 1.4426950408889634, PAL_EPSILON * 10 }, // expected: log2(e) - { 1, 0, 1.5707963267948966, PAL_EPSILON * 10 }, // expected: pi / 2 - { PAL_POSINF, 0, 1.5707963267948966, PAL_EPSILON * 10 }, // expected: pi / 2 - { PAL_POSINF, 1, 1.5707963267948966, PAL_EPSILON * 10 }, // expected: pi / 2 - { 0.74398033695749319, -0.66820151019031295, 2.3025850929940457, PAL_EPSILON * 10 }, // expected: ln(10) - { 0.41078129050290870, -0.91173391478696510, 2.7182818284590452, PAL_EPSILON * 10 }, // expected: e - { 0, -1, 3.1415926535897932, PAL_EPSILON * 10 }, // expected: pi - { 1, PAL_POSINF, 0, PAL_EPSILON }, - }; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - const double pi = 3.1415926535897932; - - atan2_test1_validate( tests[i].y, tests[i].x, tests[i].expected, tests[i].variance); - atan2_test1_validate(-tests[i].y, tests[i].x, -tests[i].expected, tests[i].variance); - atan2_test1_validate( tests[i].y, -tests[i].x, pi - tests[i].expected, tests[i].variance); - atan2_test1_validate(-tests[i].y, -tests[i].x, tests[i].expected - pi, tests[i].variance); - } - - atan2_test1_validate_isnan(PAL_NEGINF, PAL_NAN); - atan2_test1_validate_isnan(PAL_NAN, PAL_NEGINF); - atan2_test1_validate_isnan(PAL_NAN, PAL_POSINF); - atan2_test1_validate_isnan(PAL_POSINF, PAL_NAN); - - atan2_test1_validate_isnan(PAL_NAN, -1); - atan2_test1_validate_isnan(PAL_NAN, -0.0); - atan2_test1_validate_isnan(PAL_NAN, 0); - atan2_test1_validate_isnan(PAL_NAN, 1); - - atan2_test1_validate_isnan(-1, PAL_NAN); - atan2_test1_validate_isnan(-0.0, PAL_NAN); - atan2_test1_validate_isnan( 0, PAL_NAN); - atan2_test1_validate_isnan( 1, PAL_NAN); - - atan2_test1_validate_isnan(PAL_NAN, PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/atan2f/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/atan2f/test1/test1.cpp deleted file mode 100644 index f5915b3a0e1c25..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/atan2f/test1/test1.cpp +++ /dev/null @@ -1,146 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Tests that atan2f returns correct values for a subset of values. -** Tests with positive and negative values of x and y to ensure -** atan2f is returning results from the correct quadrant. -** -**===================================================================*/ - -#include - -// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (6-9 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON -// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use -// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10. -#define PAL_EPSILON 4.76837158e-07 - -#define PAL_NAN sqrtf(-1.0f) -#define PAL_POSINF -logf(0.0f) -#define PAL_NEGINF logf(0.0f) - -struct test -{ - float y; /* second component of the value to test the function with */ - float x; /* first component of the value to test the function with */ - float expected; /* expected result */ - float variance; /* maximum delta between the expected and actual result */ -}; - -/** - * atan2f_test1_validate - * - * test validation function - */ -void __cdecl atan2f_test1_validate(float y, float x, float expected, float variance) -{ - float result = atan2f(y, x); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - float delta = fabsf(result - expected); - - if (delta > variance) - { - Fail("atan2f(%g, %g) returned %10.9g when it should have returned %10.9g", - y, x, result, expected); - } -} - -/** - * atan2f_test1_validate - * - * test validation function for values returning NaN - */ -void __cdecl atan2f_test1_validate_isnan(float y, float x) -{ - float result = atan2f(y, x); - - if (!_isnanf(result)) - { - Fail("atan2f(%g, %g) returned %10.9g when it should have returned %10.9g", - y, x, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -PALTEST(c_runtime_atan2f_test1_paltest_atan2f_test1, "c_runtime/atan2f/test1/paltest_atan2f_test1") -{ - struct test tests[] = - { - /* y x expected variance */ - { 0, PAL_POSINF, 0, PAL_EPSILON }, - { 0, 0, 0, PAL_EPSILON }, - { 0.312961796f, 0.949765715f, 0.318309886f, PAL_EPSILON }, // expected: 1 / pi - { 0.420770483f, 0.907167129f, 0.434294482f, PAL_EPSILON }, // expected: logf10f(e) - { 0.594480769f, 0.804109828f, 0.636619772f, PAL_EPSILON }, // expected: 2 / pi - { 0.638961276f, 0.769238901f, 0.693147181f, PAL_EPSILON }, // expected: ln(2) - { 0.649636939f, 0.760244597f, 0.707106781f, PAL_EPSILON }, // expected: 1 / sqrtf(2) - { 0.707106781f, 0.707106781f, 0.785398163f, PAL_EPSILON }, // expected: pi / 4, value: 1 / sqrtf(2) - { 1, 1, 0.785398163f, PAL_EPSILON }, // expected: pi / 4 - { PAL_POSINF, PAL_POSINF, 0.785398163f, PAL_EPSILON }, // expected: pi / 4 - { 0.841470985f, 0.540302306f, 1, PAL_EPSILON * 10 }, - { 0.903719457f, 0.428125148f, 1.12837917f, PAL_EPSILON * 10 }, // expected: 2 / sqrtf(pi) - { 0.987765946f, 0.155943695f, 1.41421356f, PAL_EPSILON * 10 }, // expected: sqrtf(2) - { 0.991806244f, 0.127751218f, 1.44269504f, PAL_EPSILON * 10 }, // expected: logf2(e) - { 1, 0, 1.57079633f, PAL_EPSILON * 10 }, // expected: pi / 2 - { PAL_POSINF, 0, 1.57079633f, PAL_EPSILON * 10 }, // expected: pi / 2 - { PAL_POSINF, 1, 1.57079633f, PAL_EPSILON * 10 }, // expected: pi / 2 - { 0.743980337f, -0.668201510f, 2.30258509f, PAL_EPSILON * 10 }, // expected: ln(10) - { 0.410781291f, -0.911733915f, 2.71828183f, PAL_EPSILON * 10 }, // expected: e - { 0, -1, 3.14159265f, PAL_EPSILON * 10 }, // expected: pi - { 1, PAL_POSINF, 0, PAL_EPSILON }, - }; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - const float pi = 3.14159265f; - - atan2f_test1_validate( tests[i].y, tests[i].x, tests[i].expected, tests[i].variance); - atan2f_test1_validate(-tests[i].y, tests[i].x, -tests[i].expected, tests[i].variance); - atan2f_test1_validate( tests[i].y, -tests[i].x, pi - tests[i].expected, tests[i].variance); - atan2f_test1_validate(-tests[i].y, -tests[i].x, tests[i].expected - pi, tests[i].variance); - } - - atan2f_test1_validate_isnan(PAL_NEGINF, PAL_NAN); - atan2f_test1_validate_isnan(PAL_NAN, PAL_NEGINF); - atan2f_test1_validate_isnan(PAL_NAN, PAL_POSINF); - atan2f_test1_validate_isnan(PAL_POSINF, PAL_NAN); - - atan2f_test1_validate_isnan(PAL_NAN, -1); - atan2f_test1_validate_isnan(PAL_NAN, -0.0f); - atan2f_test1_validate_isnan(PAL_NAN, 0); - atan2f_test1_validate_isnan(PAL_NAN, 1); - - atan2f_test1_validate_isnan(-1, PAL_NAN); - atan2f_test1_validate_isnan(-0.0f, PAL_NAN); - atan2f_test1_validate_isnan( 0, PAL_NAN); - atan2f_test1_validate_isnan( 1, PAL_NAN); - - atan2f_test1_validate_isnan(PAL_NAN, PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/atanf/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/atanf/test1/test1.cpp deleted file mode 100644 index 518775f1f9c3e6..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/atanf/test1/test1.cpp +++ /dev/null @@ -1,126 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that atanf return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabs -** -**===========================================================================*/ - -#include - -// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (6-9 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON -// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use -// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10. -#define PAL_EPSILON 4.76837158e-07 - -#define PAL_NAN sqrtf(-1.0f) -#define PAL_POSINF -logf(0.0f) -#define PAL_NEGINF logf(0.0f) - -/** - * Helper test structure - */ -struct test -{ - float value; /* value to test the function with */ - float expected; /* expected result */ - float variance; /* maximum delta between the expected and actual result */ -}; - -/** - * atanf_test1_validate - * - * test validation function - */ -void __cdecl atanf_test1_validate(float value, float expected, float variance) -{ - float result = atanf(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - float delta = fabsf(result - expected); - - if (delta > variance) - { - Fail("atanf(%g) returned %10.9g when it should have returned %10.9g", - value, result, expected); - } -} - -/** - * atanf_test1_validate - * - * test validation function for values returning NaN - */ -void __cdecl atanf_test1_validate_isnan(float value) -{ - float result = atanf(value); - - if (!_isnanf(result)) - { - Fail("atanf(%g) returned %10.9g when it should have returned %10.9g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -PALTEST(c_runtime_atanf_test1_paltest_atanf_test1, "c_runtime/atanf/test1/paltest_atanf_test1") -{ - struct test tests[] = - { - /* value expected variance */ - { 0, 0, PAL_EPSILON }, - { 0.329514733f, 0.318309886f, PAL_EPSILON }, // expected: 1 / pi - { 0.450549534f, 0.423310825f, PAL_EPSILON }, // expected: pi - e - { 0.463829067f, 0.434294482f, PAL_EPSILON }, // expected: logf10f(e) - { 0.739302950f, 0.636619772f, PAL_EPSILON }, // expected: 2 / pi - { 0.830640878f, 0.693147181f, PAL_EPSILON }, // expected: ln(2) - { 0.854510432f, 0.707106781f, PAL_EPSILON }, // expected: 1 / sqrtf(2) - { 1, 0.785398163f, PAL_EPSILON }, // expected: pi / 4 - { 1.11340715f, 0.839007561f, PAL_EPSILON }, // expected: pi - ln(10) - { 1.55740772f, 1, PAL_EPSILON * 10 }, - { 2.11087684f, 1.12837917f, PAL_EPSILON * 10 }, // expected: 2 / sqrtf(pi) - { 6.33411917f, 1.41421356f, PAL_EPSILON * 10 }, // expected: sqrtf(2) - { 7.76357567f, 1.44269504f, PAL_EPSILON * 10 }, // expected: logf2(e) - { PAL_POSINF, 1.57079633f, PAL_EPSILON * 10 }, // expected: pi / 2 - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - atanf_test1_validate( tests[i].value, tests[i].expected, tests[i].variance); - atanf_test1_validate(-tests[i].value, -tests[i].expected, tests[i].variance); - } - - atanf_test1_validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/atanh/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/atanh/test1/test1.cpp deleted file mode 100644 index 24a042826e0917..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/atanh/test1/test1.cpp +++ /dev/null @@ -1,129 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that atanh return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabs -** -**===========================================================================*/ - -#include - -// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (15-17 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use -// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx -// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will -// use PAL_EPSILON * 10. -#define PAL_EPSILON 8.8817841970012523e-16 - -#define PAL_NAN sqrt(-1.0) -#define PAL_POSINF -log(0.0) -#define PAL_NEGINF log(0.0) - -/** - * Helper test structure - */ -struct test -{ - double value; /* value to test the function with */ - double expected; /* expected result */ - double variance; /* maximum delta between the expected and actual result */ -}; - -/** - * atanh_test1_validate - * - * test validation function - */ -void __cdecl atanh_test1_validate(double value, double expected, double variance) -{ - double result = atanh(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - double delta = fabs(result - expected); - - if (delta > variance) - { - Fail("atanh(%g) returned %20.17g when it should have returned %20.17g", - value, result, expected); - } -} - -/** - * atanh_test1_validate - * - * test validation function for values returning NaN - */ -void __cdecl atanh_test1_validate_isnan(double value) -{ - double result = atanh(value); - - if (!_isnan(result)) - { - Fail("atanh(%g) returned %20.17g when it should have returned %20.17g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -PALTEST(c_runtime_atanh_test1_paltest_atanh_test1, "c_runtime/atanh/test1/paltest_atanh_test1") -{ - struct test tests[] = - { - /* value expected variance */ - { 0, 0, PAL_EPSILON }, - { 0.30797791269089433, 0.31830988618379067, PAL_EPSILON }, // expected: 1 / pi - { 0.40890401183401433, 0.43429448190325183, PAL_EPSILON }, // expected: log10(e) - { 0.56259360033158334, 0.63661977236758134, PAL_EPSILON }, // expected: 2 / pi - { 0.6, 0.69314718055994531, PAL_EPSILON }, // expected: ln(2) - { 0.60885936501391381, 0.70710678118654752, PAL_EPSILON }, // expected: 1 / sqrt(2) - { 0.65579420263267244, 0.78539816339744831, PAL_EPSILON }, // expected: pi / 4 - { 0.76159415595576489, 1, PAL_EPSILON * 10 }, - { 0.81046380599898809, 1.1283791670955126, PAL_EPSILON * 10 }, // expected: 2 / sqrt(pi) - { 0.88838556158566054, 1.4142135623730950, PAL_EPSILON * 10 }, // expected: sqrt(2) - { 0.89423894585503855, 1.4426950408889634, PAL_EPSILON * 10 }, // expected: log2(e) - { 0.91715233566727435, 1.5707963267948966, PAL_EPSILON * 10 }, // expected: pi / 2 - { 0.98019801980198020, 2.3025850929940457, PAL_EPSILON * 10 }, // expected: ln(10) - { 0.99132891580059984, 2.7182818284590452, PAL_EPSILON * 10 }, // expected: e - { 0.99627207622074994, 3.1415926535897932, PAL_EPSILON * 10 }, // expected: pi - { 1, PAL_POSINF, PAL_EPSILON * 10 } - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - atanh_test1_validate( tests[i].value, tests[i].expected, tests[i].variance); - atanh_test1_validate(-tests[i].value, -tests[i].expected, tests[i].variance); - } - - atanh_test1_validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/atanhf/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/atanhf/test1/test1.cpp deleted file mode 100644 index d8d184f905fbed..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/atanhf/test1/test1.cpp +++ /dev/null @@ -1,128 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that atanhf return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabs -** -**===========================================================================*/ - -#include - -// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (6-9 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON -// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use -// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10. -#define PAL_EPSILON 4.76837158e-07 - -#define PAL_NAN sqrtf(-1.0f) -#define PAL_POSINF -logf(0.0f) -#define PAL_NEGINF logf(0.0f) - -/** - * Helper test structure - */ -struct test -{ - float value; /* value to test the function with */ - float expected; /* expected result */ - float variance; /* maximum delta between the expected and actual result */ -}; - -/** - * atanhf_test1_validate - * - * test validation function - */ -void __cdecl atanhf_test1_validate(float value, float expected, float variance) -{ - float result = atanhf(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - float delta = fabsf(result - expected); - - if (delta > variance) - { - Fail("atanhf(%g) returned %10.9g when it should have returned %10.9g", - value, result, expected); - } -} - -/** - * atanhf_test1_validate - * - * test validation function for values returning NaN - */ -void __cdecl atanhf_test1_validate_isnan(float value) -{ - float result = atanhf(value); - - if (!_isnanf(result)) - { - Fail("atanhf(%g) returned %10.9g when it should have returned %10.9g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -PALTEST(c_runtime_atanhf_test1_paltest_atanhf_test1, "c_runtime/atanhf/test1/paltest_atanhf_test1") -{ - struct test tests[] = - { - /* value expected variance */ - { 0, 0, PAL_EPSILON }, - { 0.307977913f, 0.318309886f, PAL_EPSILON }, // expected: 1 / pi - { 0.408904012f, 0.434294482f, PAL_EPSILON }, // expected: log10f(e) - { 0.562593600f, 0.636619772f, PAL_EPSILON }, // expected: 2 / pi - { 0.6f, 0.693147181f, PAL_EPSILON }, // expected: ln(2) - { 0.608859365f, 0.707106781f, PAL_EPSILON }, // expected: 1 / sqrtf(2) - { 0.655794203f, 0.785398163f, PAL_EPSILON }, // expected: pi / 4 - { 0.761594156f, 1, PAL_EPSILON * 10 }, - { 0.810463806f, 1.12837917f, PAL_EPSILON * 10 }, // expected: 2 / sqrtf(pi) - { 0.888385562f, 1.41421356f, PAL_EPSILON * 10 }, // expected: sqrtf(2) - { 0.894238946f, 1.44269504f, PAL_EPSILON * 10 }, // expected: logf2(e) - { 0.917152336f, 1.57079633f, PAL_EPSILON * 10 }, // expected: pi / 2 - { 0.980198020f, 2.30258509f, PAL_EPSILON * 10 }, // expected: ln(10) - { 0.991328916f, 2.71828183f, PAL_EPSILON * 10 }, // expected: e - { 0.996272076f, 3.14159265f, PAL_EPSILON * 10 }, // expected: pi - { 1, PAL_POSINF, PAL_EPSILON * 10 } - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - atanhf_test1_validate( tests[i].value, tests[i].expected, tests[i].variance); - atanhf_test1_validate(-tests[i].value, -tests[i].expected, tests[i].variance); - } - - atanhf_test1_validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/cbrt/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/cbrt/test1/test1.cpp deleted file mode 100644 index 4cc57c27e4915e..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/cbrt/test1/test1.cpp +++ /dev/null @@ -1,122 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Call the cbrt function on a positive value, a positive value -** with a decimal and on the maximum possible double value. -** -** -**===================================================================*/ - -#include - -// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (15-17 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use -// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx -// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will -// use PAL_EPSILON * 10. -#define PAL_EPSILON 8.8817841970012523e-16 - -#define PAL_NAN sqrt(-1.0) -#define PAL_POSINF -log(0.0) -#define PAL_NEGINF log(0.0) - -/** - * Helper test structure - */ -struct test -{ - double value; /* value to test the function with */ - double expected; /* expected result */ - double variance; /* maximum delta between the expected and actual result */ -}; - -/** - * cbrt_test1_validate - * - * test validation function - */ -void __cdecl cbrt_test1_validate(double value, double expected, double variance) -{ - double result = cbrt(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - double delta = fabs(result - expected); - - if (delta > variance) - { - Fail("cbrt(%g) returned %20.17g when it should have returned %20.17g", - value, result, expected); - } -} - -/** - * cbrt_test1_validate - * - * test validation function for values returning NaN - */ -void __cdecl cbrt_test1_validate_isnan(double value) -{ - double result = cbrt(value); - - if (!_isnan(result)) - { - Fail("cbrt(%g) returned %20.17g when it should have returned %20.17g", - value, result, PAL_NAN); - } -} - -PALTEST(c_runtime_cbrt_test1_paltest_cbrt_test1, "c_runtime/cbrt/test1/paltest_cbrt_test1") -{ - struct test tests[] = - { - /* value expected variance */ - { 0.31830988618379067, 0.68278406325529568, PAL_EPSILON }, // value: 1 / pi - { 0.43429448190325183, 0.75728863133090766, PAL_EPSILON }, // value: log10(e) - { 0.63661977236758134, 0.86025401382809963, PAL_EPSILON }, // value: 2 / pi - { 0.69314718055994531, 0.88499704450051772, PAL_EPSILON }, // value: ln(2) - { 0.70710678118654752, 0.89089871814033930, PAL_EPSILON }, // value: 1 / sqrt(2) - { 0.78539816339744831, 0.92263507432201421, PAL_EPSILON }, // value: pi / 4 - { 1, 1, PAL_EPSILON * 10 }, - { 1.1283791670955126, 1.0410821966965807, PAL_EPSILON * 10 }, // value: 2 / sqrt(pi) - { 1.4142135623730950, 1.1224620483093730, PAL_EPSILON * 10 }, // value: sqrt(2) - { 1.4426950408889634, 1.1299472763373901, PAL_EPSILON * 10 }, // value: log2(e) - { 1.5707963267948966, 1.1624473515096265, PAL_EPSILON * 10 }, // value: pi / 2 - { 2.3025850929940457, 1.3205004784536852, PAL_EPSILON * 10 }, // value: ln(10) - { 2.7182818284590452, 1.3956124250860895, PAL_EPSILON * 10 }, // value: e - { 3.1415926535897932, 1.4645918875615233, PAL_EPSILON * 10 }, // value: pi - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - cbrt_test1_validate(-0.0, -0.0, PAL_EPSILON); - cbrt_test1_validate( 0.0, 0.0, PAL_EPSILON); - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - cbrt_test1_validate(tests[i].value, tests[i].expected, tests[i].variance); - cbrt_test1_validate(-tests[i].value, -tests[i].expected, tests[i].variance); - } - - cbrt_test1_validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/cbrtf/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/cbrtf/test1/test1.cpp deleted file mode 100644 index 8879a11ed77cee..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/cbrtf/test1/test1.cpp +++ /dev/null @@ -1,121 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Call the cbrtf function on a positive value, a positive value -** with a decimal and on the maximum possible float value. -** -** -**===================================================================*/ - -#include - -// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (6-9 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON -// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use -// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10. -#define PAL_EPSILON 4.76837158e-07 - -#define PAL_NAN sqrtf(-1.0f) -#define PAL_POSINF -logf(0.0f) -#define PAL_NEGINF logf(0.0f) - -/** - * Helper test structure - */ -struct test -{ - float value; /* value to test the function with */ - float expected; /* expected result */ - float variance; /* maximum delta between the expected and actual result */ -}; - -/** - * cbrtf_test1_validate - * - * test validation function - */ -void __cdecl cbrtf_test1_validate(float value, float expected, float variance) -{ - float result = cbrtf(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - float delta = fabsf(result - expected); - - if (delta > variance) - { - Fail("cbrtf(%g) returned %10.9g when it should have returned %10.9g", - value, result, expected); - } -} - -/** - * cbrtf_test1_validate - * - * test validation function for values returning NaN - */ -void __cdecl cbrtf_test1_validate_isnan(float value) -{ - float result = cbrtf(value); - - if (!_isnanf(result)) - { - Fail("cbrtf(%g) returned %10.9g when it should have returned %10.9g", - value, result, PAL_NAN); - } -} - -PALTEST(c_runtime_cbrtf_test1_paltest_cbrtf_test1, "c_runtime/cbrtf/test1/paltest_cbrtf_test1") -{ - struct test tests[] = - { - /* value expected variance */ - { 0.318309886f, 0.682784063f, PAL_EPSILON }, // value: 1 / pi - { 0.434294482f, 0.757288631f, PAL_EPSILON }, // value: log10f(e) - { 0.636619772f, 0.860254014f, PAL_EPSILON }, // value: 2 / pi - { 0.693147181f, 0.884997045f, PAL_EPSILON }, // value: ln(2) - { 0.707106781f, 0.890898718f, PAL_EPSILON }, // value: 1 / sqrtf(2) - { 0.785398163f, 0.922635074f, PAL_EPSILON }, // value: pi / 4 - { 1, 1, PAL_EPSILON * 10 }, - { 1.12837917f, 1.04108220f, PAL_EPSILON * 10 }, // value: 2 / sqrtf(pi) - { 1.41421356f, 1.12246205f, PAL_EPSILON * 10 }, // value: sqrtf(2) - { 1.44269504f, 1.12994728f, PAL_EPSILON * 10 }, // value: logf2(e) - { 1.57079633f, 1.16244735f, PAL_EPSILON * 10 }, // value: pi / 2 - { 2.30258509f, 1.32050048f, PAL_EPSILON * 10 }, // value: ln(10) - { 2.71828183f, 1.39561243f, PAL_EPSILON * 10 }, // value: e - { 3.14159265f, 1.46459189f, PAL_EPSILON * 10 }, // value: pi - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - cbrtf_test1_validate(-0.0f, -0.0f, PAL_EPSILON); - cbrtf_test1_validate( 0.0f, 0.0f, PAL_EPSILON); - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - cbrtf_test1_validate(tests[i].value, tests[i].expected, tests[i].variance); - cbrtf_test1_validate(-tests[i].value, -tests[i].expected, tests[i].variance); - } - - cbrtf_test1_validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/ceil/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/ceil/test1/test1.cpp deleted file mode 100644 index 3f1d71e625c7d6..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/ceil/test1/test1.cpp +++ /dev/null @@ -1,131 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Tests ceil with simple positive and negative values. Also tests -** extreme cases like extremely small values and positive and -** negative infinity. Makes sure that calling ceil on NaN returns -** NaN -** -**==========================================================================*/ - -#include - -// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (15-17 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use -// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx -// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will -// use PAL_EPSILON * 10. -#define PAL_EPSILON 8.8817841970012523e-16 - -#define PAL_NAN sqrt(-1.0) -#define PAL_POSINF -log(0.0) -#define PAL_NEGINF log(0.0) - -/** - * Helper test structure - */ -struct test -{ - double value; /* value to test the function with */ - double expected; /* expected result */ - double variance; /* maximum delta between the expected and actual result */ -}; - -/** - * ceil_test1_validate - * - * test validation function - */ -void __cdecl ceil_test1_validate(double value, double expected, double variance) -{ - double result = ceil(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - double delta = fabs(result - expected); - - if (delta > variance) - { - Fail("ceil(%g) returned %20.17g when it should have returned %20.17g", - value, result, expected); - } -} - -/** - * ceil_test1_validate - * - * test validation function for values returning NaN - */ -void __cdecl ceil_test1_validate_isnan(double value) -{ - double result = ceil(value); - - if (!_isnan(result)) - { - Fail("ceil(%g) returned %20.17g when it should have returned %20.17g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -PALTEST(c_runtime_ceil_test1_paltest_ceil_test1, "c_runtime/ceil/test1/paltest_ceil_test1") -{ - struct test tests[] = - { - /* value expected variance */ - { 0.31830988618379067, 1, PAL_EPSILON * 10 }, // value: 1 / pi - { 0.43429448190325183, 1, PAL_EPSILON * 10 }, // value: log10(e) - { 0.63661977236758134, 1, PAL_EPSILON * 10 }, // value: 2 / pi - { 0.69314718055994531, 1, PAL_EPSILON * 10 }, // value: ln(2) - { 0.70710678118654752, 1, PAL_EPSILON * 10 }, // value: 1 / sqrt(2) - { 0.78539816339744831, 1, PAL_EPSILON * 10 }, // value: pi / 4 - { 1.1283791670955126, 2, PAL_EPSILON * 10 }, // value: 2 / sqrt(pi) - { 1.4142135623730950, 2, PAL_EPSILON * 10 }, // value: sqrt(2) - { 1.4426950408889634, 2, PAL_EPSILON * 10 }, // value: log2(e) - { 1.5707963267948966, 2, PAL_EPSILON * 10 }, // value: pi / 2 - { 2.3025850929940457, 3, PAL_EPSILON * 10 }, // value: ln(10) - { 2.7182818284590452, 3, PAL_EPSILON * 10 }, // value: e - { 3.1415926535897932, 4, PAL_EPSILON * 10 }, // value: pi - { PAL_POSINF, PAL_POSINF, 0 } - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - ceil_test1_validate( 0, 0, PAL_EPSILON); - ceil_test1_validate(-0.0, 0, PAL_EPSILON); - - ceil_test1_validate( 1, 1, PAL_EPSILON * 10); - ceil_test1_validate(-1.0, -1, PAL_EPSILON * 10); - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - ceil_test1_validate( tests[i].value, tests[i].expected, tests[i].variance); - ceil_test1_validate(-tests[i].value, 1 - tests[i].expected, tests[i].variance); - } - - ceil_test1_validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/ceilf/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/ceilf/test1/test1.cpp deleted file mode 100644 index cf237ea8eb95bc..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/ceilf/test1/test1.cpp +++ /dev/null @@ -1,130 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Tests ceilf with simple positive and negative values. Also tests -** extreme cases like extremely small values and positive and -** negative infinity. Makes sure that calling ceilf on NaN returns -** NaN -** -**==========================================================================*/ - -#include - -// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (6-9 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON -// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use -// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10. -#define PAL_EPSILON 4.76837158e-07 - -#define PAL_NAN sqrtf(-1.0f) -#define PAL_POSINF -logf(0.0f) -#define PAL_NEGINF logf(0.0f) - -/** - * Helper test structure - */ -struct test -{ - float value; /* value to test the function with */ - float expected; /* expected result */ - float variance; /* maximum delta between the expected and actual result */ -}; - -/** - * ceilf_test1_validate - * - * test validation function - */ -void __cdecl ceilf_test1_validate(float value, float expected, float variance) -{ - float result = ceilf(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - float delta = fabsf(result - expected); - - if (delta > variance) - { - Fail("ceilf(%g) returned %10.9g when it should have returned %10.9g", - value, result, expected); - } -} - -/** - * ceilf_test1_validate - * - * test validation function for values returning NaN - */ -void __cdecl ceilf_test1_validate_isnan(float value) -{ - float result = ceilf(value); - - if (!_isnanf(result)) - { - Fail("ceilf(%g) returned %10.9g when it should have returned %10.9g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -PALTEST(c_runtime_ceilf_test1_paltest_ceilf_test1, "c_runtime/ceilf/test1/paltest_ceilf_test1") -{ - struct test tests[] = - { - /* value expected variance */ - { 0.318309886f, 1, PAL_EPSILON * 10 }, // value: 1 / pi - { 0.434294482f, 1, PAL_EPSILON * 10 }, // value: log10f(e) - { 0.636619772f, 1, PAL_EPSILON * 10 }, // value: 2 / pi - { 0.693147181f, 1, PAL_EPSILON * 10 }, // value: ln(2) - { 0.707106781f, 1, PAL_EPSILON * 10 }, // value: 1 / sqrtf(2) - { 0.785398163f, 1, PAL_EPSILON * 10 }, // value: pi / 4 - { 1.12837917f, 2, PAL_EPSILON * 10 }, // value: 2 / sqrtf(pi) - { 1.41421356f, 2, PAL_EPSILON * 10 }, // value: sqrtf(2) - { 1.44269504f, 2, PAL_EPSILON * 10 }, // value: logf2(e) - { 1.57079633f, 2, PAL_EPSILON * 10 }, // value: pi / 2 - { 2.30258509f, 3, PAL_EPSILON * 10 }, // value: ln(10) - { 2.71828183f, 3, PAL_EPSILON * 10 }, // value: e - { 3.14159265f, 4, PAL_EPSILON * 10 }, // value: pi - { PAL_POSINF, PAL_POSINF, 0 } - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - ceilf_test1_validate( 0, 0, PAL_EPSILON); - ceilf_test1_validate(-0.0f, 0, PAL_EPSILON); - - ceilf_test1_validate( 1, 1, PAL_EPSILON * 10); - ceilf_test1_validate(-1.0f, -1, PAL_EPSILON * 10); - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - ceilf_test1_validate( tests[i].value, tests[i].expected, tests[i].variance); - ceilf_test1_validate(-tests[i].value, 1 - tests[i].expected, tests[i].variance); - } - - ceilf_test1_validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/cos/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/cos/test1/test1.cpp deleted file mode 100644 index d574895731d52d..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/cos/test1/test1.cpp +++ /dev/null @@ -1,130 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that cos return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabs -** -**===========================================================================*/ - -#include - -// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (15-17 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use -// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx -// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will -// use PAL_EPSILON * 10. -#define PAL_EPSILON 8.8817841970012523e-16 - -#define PAL_NAN sqrt(-1.0) -#define PAL_POSINF -log(0.0) -#define PAL_NEGINF log(0.0) - -/** - * Helper test structure - */ -struct test -{ - double value; /* value to test the function with */ - double expected; /* expected result */ - double variance; /* maximum delta between the expected and actual result */ -}; - -/** - * cos_test1_validate - * - * test validation function - */ -void __cdecl cos_test1_validate(double value, double expected, double variance) -{ - double result = cos(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - double delta = fabs(result - expected); - - if (delta > variance) - { - Fail("cos(%g) returned %20.17g when it should have returned %20.17g", - value, result, expected); - } -} - -/** - * cos_test1_validate - * - * test validation function for values returning NaN - */ -void __cdecl cos_test1_validate_isnan(double value) -{ - double result = cos(value); - - if (!_isnan(result)) - { - Fail("cos(%g) returned %20.17g when it should have returned %20.17g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -PALTEST(c_runtime_cos_test1_paltest_cos_test1, "c_runtime/cos/test1/paltest_cos_test1") -{ - struct test tests[] = - { - /* value expected variance */ - { 0, 1, PAL_EPSILON * 10 }, - { 0.31830988618379067, 0.94976571538163866, PAL_EPSILON }, // value: 1 / pi - { 0.43429448190325183, 0.90716712923909839, PAL_EPSILON }, // value: log10(e) - { 0.63661977236758134, 0.80410982822879171, PAL_EPSILON }, // value: 2 / pi - { 0.69314718055994531, 0.76923890136397213, PAL_EPSILON }, // value: ln(2) - { 0.70710678118654752, 0.76024459707563015, PAL_EPSILON }, // value: 1 / sqrt(2) - { 0.78539816339744831, 0.70710678118654752, PAL_EPSILON }, // value: pi / 4, expected: 1 / sqrt(2) - { 1, 0.54030230586813972, PAL_EPSILON }, - { 1.1283791670955126, 0.42812514788535792, PAL_EPSILON }, // value: 2 / sqrt(pi) - { 1.4142135623730950, 0.15594369476537447, PAL_EPSILON }, // value: sqrt(2) - { 1.4426950408889634, 0.12775121753523991, PAL_EPSILON }, // value: log2(e) - { 1.5707963267948966, 0, PAL_EPSILON }, // value: pi / 2 - { 2.3025850929940457, -0.66820151019031295, PAL_EPSILON }, // value: ln(10) - { 2.7182818284590452, -0.91173391478696510, PAL_EPSILON }, // value: e - { 3.1415926535897932, -1, PAL_EPSILON * 10 }, // value: pi - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - cos_test1_validate( tests[i].value, tests[i].expected, tests[i].variance); - cos_test1_validate(-tests[i].value, tests[i].expected, tests[i].variance); - } - - cos_test1_validate_isnan(PAL_NEGINF); - cos_test1_validate_isnan(PAL_NAN); - cos_test1_validate_isnan(PAL_POSINF); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/cosf/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/cosf/test1/test1.cpp deleted file mode 100644 index ed3a4512b7fe7e..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/cosf/test1/test1.cpp +++ /dev/null @@ -1,129 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that cosf return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabs -** -**===========================================================================*/ - -#include - -// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (6-9 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON -// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use -// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10. -#define PAL_EPSILON 4.76837158e-07 - -#define PAL_NAN sqrtf(-1.0f) -#define PAL_POSINF -logf(0.0f) -#define PAL_NEGINF logf(0.0f) - -/** - * Helper test structure - */ -struct test -{ - float value; /* value to test the function with */ - float expected; /* expected result */ - float variance; /* maximum delta between the expected and actual result */ -}; - -/** - * cosf_test1_validate - * - * test validation function - */ -void __cdecl cosf_test1_validate(float value, float expected, float variance) -{ - float result = cosf(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - float delta = fabsf(result - expected); - - if (delta > variance) - { - Fail("cosf(%g) returned %10.9g when it should have returned %10.9g", - value, result, expected); - } -} - -/** - * cosf_test1_validate - * - * test validation function for values returning NaN - */ -void __cdecl cosf_test1_validate_isnan(float value) -{ - float result = cosf(value); - - if (!_isnanf(result)) - { - Fail("cosf(%g) returned %10.9g when it should have returned %10.9g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -PALTEST(c_runtime_cosf_test1_paltest_cosf_test1, "c_runtime/cosf/test1/paltest_cosf_test1") -{ - struct test tests[] = - { - /* value expected variance */ - { 0, 1, PAL_EPSILON * 10 }, - { 0.318309886f, 0.949765715f, PAL_EPSILON }, // value: 1 / pi - { 0.434294482f, 0.907167129f, PAL_EPSILON }, // value: log10f(e) - { 0.636619772f, 0.804109828f, PAL_EPSILON }, // value: 2 / pi - { 0.693147181f, 0.769238901f, PAL_EPSILON }, // value: ln(2) - { 0.707106781f, 0.760244597f, PAL_EPSILON }, // value: 1 / sqrtf(2) - { 0.785398163f, 0.707106781f, PAL_EPSILON }, // value: pi / 4, expected: 1 / sqrtf(2) - { 1, 0.540302306f, PAL_EPSILON }, - { 1.12837917f, 0.428125148f, PAL_EPSILON }, // value: 2 / sqrtf(pi) - { 1.41421356f, 0.155943695f, PAL_EPSILON }, // value: sqrtf(2) - { 1.44269504f, 0.127751218f, PAL_EPSILON }, // value: logf2(e) - { 1.57079633f, 0, PAL_EPSILON }, // value: pi / 2 - { 2.30258509f, -0.668201510f, PAL_EPSILON }, // value: ln(10) - { 2.71828183f, -0.911733918f, PAL_EPSILON }, // value: e - { 3.14159265f, -1, PAL_EPSILON * 10 }, // value: pi - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - cosf_test1_validate( tests[i].value, tests[i].expected, tests[i].variance); - cosf_test1_validate(-tests[i].value, tests[i].expected, tests[i].variance); - } - - cosf_test1_validate_isnan(PAL_NEGINF); - cosf_test1_validate_isnan(PAL_NAN); - cosf_test1_validate_isnan(PAL_POSINF); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/cosh/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/cosh/test1/test1.cpp deleted file mode 100644 index 78518b78e0e45f..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/cosh/test1/test1.cpp +++ /dev/null @@ -1,129 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that cosh return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabs -** -**===========================================================================*/ - -#include - -// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (15-17 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use -// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx -// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will -// use PAL_EPSILON * 10. -#define PAL_EPSILON 8.8817841970012523e-16 - -#define PAL_NAN sqrt(-1.0) -#define PAL_POSINF -log(0.0) -#define PAL_NEGINF log(0.0) - -/** - * Helper test structure - */ -struct test -{ - double value; /* value to test the function with */ - double expected; /* expected result */ - double variance; /* maximum delta between the expected and actual result */ -}; - -/** - * cosh_test1_validate - * - * test validation function - */ -void __cdecl cosh_test1_validate(double value, double expected, double variance) -{ - double result = cosh(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - double delta = fabs(result - expected); - - if (delta > variance) - { - Fail("cosh(%g) returned %20.17g when it should have returned %20.17g", - value, result, expected); - } -} - -/** - * cosh_test1_validate - * - * test validation function for values returning PAL_NAN - */ -void __cdecl cosh_test1_validate_isnan(double value) -{ - double result = cosh(value); - - if (!_isnan(result)) - { - Fail("cosh(%g) returned %20.17g when it should have returned %20.17g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -PALTEST(c_runtime_cosh_test1_paltest_cosh_test1, "c_runtime/cosh/test1/paltest_cosh_test1") -{ - struct test tests[] = - { - /* value expected variance */ - { 0, 1, PAL_EPSILON * 10 }, - { 0.31830988618379067, 1.0510897883672876, PAL_EPSILON * 10 }, // value: 1 / pi - { 0.43429448190325183, 1.0957974645564909, PAL_EPSILON * 10 }, // value: log10(e) - { 0.63661977236758134, 1.2095794864199787, PAL_EPSILON * 10 }, // value: 2 / pi - { 0.69314718055994531, 1.25, PAL_EPSILON * 10 }, // value: ln(2) - { 0.70710678118654752, 1.2605918365213561, PAL_EPSILON * 10 }, // value: 1 / sqrt(2) - { 0.78539816339744831, 1.3246090892520058, PAL_EPSILON * 10 }, // value: pi / 4 - { 1, 1.5430806348152438, PAL_EPSILON * 10 }, - { 1.1283791670955126, 1.7071001431069344, PAL_EPSILON * 10 }, // value: 2 / sqrt(pi) - { 1.4142135623730950, 2.1781835566085709, PAL_EPSILON * 10 }, // value: sqrt(2) - { 1.4426950408889634, 2.2341880974508023, PAL_EPSILON * 10 }, // value: log2(e) - { 1.5707963267948966, 2.5091784786580568, PAL_EPSILON * 10 }, // value: pi / 2 - { 2.3025850929940457, 5.05, PAL_EPSILON * 10 }, // value: ln(10) - { 2.7182818284590452, 7.6101251386622884, PAL_EPSILON * 10 }, // value: e - { 3.1415926535897932, 11.591953275521521, PAL_EPSILON * 100 }, // value: pi - { PAL_POSINF, PAL_POSINF, 0 }, - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - cosh_test1_validate( tests[i].value, tests[i].expected, tests[i].variance); - cosh_test1_validate(-tests[i].value, tests[i].expected, tests[i].variance); - } - - cosh_test1_validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/coshf/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/coshf/test1/test1.cpp deleted file mode 100644 index 27ba18c080f433..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/coshf/test1/test1.cpp +++ /dev/null @@ -1,128 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that coshf return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabs -** -**===========================================================================*/ - -#include - -// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (6-9 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON -// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use -// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10. -#define PAL_EPSILON 4.76837158e-07 - -#define PAL_NAN sqrtf(-1.0f) -#define PAL_POSINF -logf(0.0f) -#define PAL_NEGINF logf(0.0f) - -/** - * Helper test structure - */ -struct test -{ - float value; /* value to test the function with */ - float expected; /* expected result */ - float variance; /* maximum delta between the expected and actual result */ -}; - -/** - * coshf_test1_validate - * - * test validation function - */ -void __cdecl coshf_test1_validate(float value, float expected, float variance) -{ - float result = coshf(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - float delta = fabsf(result - expected); - - if (delta > variance) - { - Fail("coshf(%g) returned %10.9g when it should have returned %10.9g", - value, result, expected); - } -} - -/** - * coshf_test1_validate - * - * test validation function for values returning PAL_NAN - */ -void __cdecl coshf_test1_validate_isnan(float value) -{ - float result = coshf(value); - - if (!_isnanf(result)) - { - Fail("coshf(%g) returned %10.9g when it should have returned %10.9g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -PALTEST(c_runtime_coshf_test1_paltest_coshf_test1, "c_runtime/coshf/test1/paltest_coshf_test1") -{ - struct test tests[] = - { - /* value expected variance */ - { 0, 1, PAL_EPSILON * 10 }, - { 0.318309886f, 1.05108979f, PAL_EPSILON * 10 }, // value: 1 / pi - { 0.434294482f, 1.09579746f, PAL_EPSILON * 10 }, // value: log10f(e) - { 0.636619772f, 1.20957949f, PAL_EPSILON * 10 }, // value: 2 / pi - { 0.693147181f, 1.25f, PAL_EPSILON * 10 }, // value: ln(2) - { 0.707106781f, 1.26059184f, PAL_EPSILON * 10 }, // value: 1 / sqrtf(2) - { 0.785398163f, 1.32460909f, PAL_EPSILON * 10 }, // value: pi / 4 - { 1, 1.54308063f, PAL_EPSILON * 10 }, - { 1.12837917f, 1.70710014f, PAL_EPSILON * 10 }, // value: 2 / sqrtf(pi) - { 1.41421356f, 2.17818356f, PAL_EPSILON * 10 }, // value: sqrtf(2) - { 1.44269504f, 2.23418810f, PAL_EPSILON * 10 }, // value: logf2(e) - { 1.57079633f, 2.50917848f, PAL_EPSILON * 10 }, // value: pi / 2 - { 2.30258509f, 5.05f, PAL_EPSILON * 10 }, // value: ln(10) - { 2.71828183f, 7.61012514f, PAL_EPSILON * 10 }, // value: e - { 3.14159265f, 11.5919533f, PAL_EPSILON * 100 }, // value: pi - { PAL_POSINF, PAL_POSINF, 0 }, - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - coshf_test1_validate( tests[i].value, tests[i].expected, tests[i].variance); - coshf_test1_validate(-tests[i].value, tests[i].expected, tests[i].variance); - } - - coshf_test1_validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/exp/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/exp/test1/test1.cpp deleted file mode 100644 index b3c8bb9307e07a..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/exp/test1/test1.cpp +++ /dev/null @@ -1,137 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Tests exp with a normal set of values. -** -**===================================================================*/ - -#include - -// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (15-17 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use -// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx -// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will -// use PAL_EPSILON * 10. -#define PAL_EPSILON 8.8817841970012523e-16 - -#define PAL_NAN sqrt(-1.0) -#define PAL_POSINF -log(0.0) -#define PAL_NEGINF log(0.0) - -/** - * Helper test structure - */ -struct test -{ - double value; /* value to test the function with */ - double expected; /* expected result */ - double variance; /* maximum delta between the expected and actual result */ -}; - -/** - * exp_test1_validate - * - * test validation function - */ -void __cdecl exp_test1_validate(double value, double expected, double variance) -{ - double result = exp(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - double delta = fabs(result - expected); - - if (delta > variance) - { - Fail("exp(%g) returned %20.17g when it should have returned %20.17g", - value, result, expected); - } -} - -/** - * exp_test1_validate - * - * test validation function for values returning NaN - */ -void __cdecl exp_test1_validate_isnan(double value) -{ - double result = exp(value); - - if (!_isnan(result)) - { - Fail("exp(%g) returned %20.17g when it should have returned %20.17g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -PALTEST(c_runtime_exp_test1_paltest_exp_test1, "c_runtime/exp/test1/paltest_exp_test1") -{ - struct test tests[] = - { - /* value expected variance */ - { PAL_NEGINF, 0, PAL_EPSILON }, - { -3.1415926535897932, 0.043213918263772250, PAL_EPSILON / 10 }, // value: -(pi) - { -2.7182818284590452, 0.065988035845312537, PAL_EPSILON / 10 }, // value: -(e) - { -2.3025850929940457, 0.1, PAL_EPSILON }, // value: -(ln(10)) - { -1.5707963267948966, 0.20787957635076191, PAL_EPSILON }, // value: -(pi / 2) - { -1.4426950408889634, 0.23629008834452270, PAL_EPSILON }, // value: -(log2(e)) - { -1.4142135623730950, 0.24311673443421421, PAL_EPSILON }, // value: -(sqrt(2)) - { -1.1283791670955126, 0.32355726390307110, PAL_EPSILON }, // value: -(2 / sqrt(pi)) - { -1, 0.36787944117144232, PAL_EPSILON }, // value: -(1) - { -0.78539816339744831, 0.45593812776599624, PAL_EPSILON }, // value: -(pi / 4) - { -0.70710678118654752, 0.49306869139523979, PAL_EPSILON }, // value: -(1 / sqrt(2)) - { -0.69314718055994531, 0.5, PAL_EPSILON }, // value: -(ln(2)) - { -0.63661977236758134, 0.52907780826773535, PAL_EPSILON }, // value: -(2 / pi) - { -0.43429448190325183, 0.64772148514180065, PAL_EPSILON }, // value: -(log10(e)) - { -0.31830988618379067, 0.72737734929521647, PAL_EPSILON }, // value: -(1 / pi) - { 0, 1, PAL_EPSILON * 10 }, - { 0.31830988618379067, 1.3748022274393586, PAL_EPSILON * 10 }, // value: 1 / pi - { 0.43429448190325183, 1.5438734439711811, PAL_EPSILON * 10 }, // value: log10(e) - { 0.63661977236758134, 1.8900811645722220, PAL_EPSILON * 10 }, // value: 2 / pi - { 0.69314718055994531, 2, PAL_EPSILON * 10 }, // value: ln(2) - { 0.70710678118654752, 2.0281149816474725, PAL_EPSILON * 10 }, // value: 1 / sqrt(2) - { 0.78539816339744831, 2.1932800507380155, PAL_EPSILON * 10 }, // value: pi / 4 - { 1, 2.7182818284590452, PAL_EPSILON * 10 }, // expected: e - { 1.1283791670955126, 3.0906430223107976, PAL_EPSILON * 10 }, // value: 2 / sqrt(pi) - { 1.4142135623730950, 4.1132503787829275, PAL_EPSILON * 10 }, // value: sqrt(2) - { 1.4426950408889634, 4.2320861065570819, PAL_EPSILON * 10 }, // value: log2(e) - { 1.5707963267948966, 4.8104773809653517, PAL_EPSILON * 10 }, // value: pi / 2 - { 2.3025850929940457, 10, PAL_EPSILON * 100 }, // value: ln(10) - { 2.7182818284590452, 15.154262241479264, PAL_EPSILON * 100 }, // value: e - { 3.1415926535897932, 23.140692632779269, PAL_EPSILON * 100 }, // value: pi - { PAL_POSINF, PAL_POSINF, 0 }, - }; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - exp_test1_validate(tests[i].value, tests[i].expected, tests[i].variance); - } - - exp_test1_validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/expf/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/expf/test1/test1.cpp deleted file mode 100644 index 72d417ff180a92..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/expf/test1/test1.cpp +++ /dev/null @@ -1,136 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Tests expf with a normal set of values. -** -**===================================================================*/ - -#include - -// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (6-9 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON -// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use -// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10. -#define PAL_EPSILON 4.76837158e-07 - -#define PAL_NAN sqrtf(-1.0f) -#define PAL_POSINF -logf(0.0f) -#define PAL_NEGINF logf(0.0f) - -/** - * Helper test structure - */ -struct test -{ - float value; /* value to test the function with */ - float expected; /* expected result */ - float variance; /* maximum delta between the expected and actual result */ -}; - -/** - * expf_test1_validate - * - * test validation function - */ -void __cdecl expf_test1_validate(float value, float expected, float variance) -{ - float result = expf(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - float delta = fabsf(result - expected); - - if (delta > variance) - { - Fail("expf(%g) returned %10.9g when it should have returned %10.9g", - value, result, expected); - } -} - -/** - * expf_test1_validate - * - * test validation function for values returning NaN - */ -void __cdecl expf_test1_validate_isnan(float value) -{ - float result = expf(value); - - if (!_isnanf(result)) - { - Fail("expf(%g) returned %10.9g when it should have returned %10.9g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -PALTEST(c_runtime_expf_test1_paltest_expf_test1, "c_runtime/expf/test1/paltest_expf_test1") -{ - struct test tests[] = - { - /* value expected variance */ - { PAL_NEGINF, 0, PAL_EPSILON }, - { -3.14159265f, 0.0432139183f, PAL_EPSILON / 10 }, // value: -(pi) - { -2.71828183f, 0.0659880358f, PAL_EPSILON / 10 }, // value: -(e) - { -2.30258509f, 0.1f, PAL_EPSILON }, // value: -(ln(10)) - { -1.57079633f, 0.207879576f, PAL_EPSILON }, // value: -(pi / 2) - { -1.44269504f, 0.236290088f, PAL_EPSILON }, // value: -(logf2(e)) - { -1.41421356f, 0.243116734f, PAL_EPSILON }, // value: -(sqrtf(2)) - { -1.12837917f, 0.323557264f, PAL_EPSILON }, // value: -(2 / sqrtf(pi)) - { -1, 0.367879441f, PAL_EPSILON }, // value: -(1) - { -0.785398163f, 0.455938128f, PAL_EPSILON }, // value: -(pi / 4) - { -0.707106781f, 0.493068691f, PAL_EPSILON }, // value: -(1 / sqrtf(2)) - { -0.693147181f, 0.5f, PAL_EPSILON }, // value: -(ln(2)) - { -0.636619772f, 0.529077808f, PAL_EPSILON }, // value: -(2 / pi) - { -0.434294482f, 0.647721485f, PAL_EPSILON }, // value: -(log10f(e)) - { -0.318309886f, 0.727377349f, PAL_EPSILON }, // value: -(1 / pi) - { 0, 1, PAL_EPSILON * 10 }, - { 0.318309886f, 1.37480223f, PAL_EPSILON * 10 }, // value: 1 / pi - { 0.434294482f, 1.54387344f, PAL_EPSILON * 10 }, // value: log10f(e) - { 0.636619772f, 1.89008116f, PAL_EPSILON * 10 }, // value: 2 / pi - { 0.693147181f, 2, PAL_EPSILON * 10 }, // value: ln(2) - { 0.707106781f, 2.02811498f, PAL_EPSILON * 10 }, // value: 1 / sqrtf(2) - { 0.785398163f, 2.19328005f, PAL_EPSILON * 10 }, // value: pi / 4 - { 1, 2.71828183f, PAL_EPSILON * 10 }, // expected: e - { 1.12837917f, 3.09064302f, PAL_EPSILON * 10 }, // value: 2 / sqrtf(pi) - { 1.41421356f, 4.11325038f, PAL_EPSILON * 10 }, // value: sqrtf(2) - { 1.44269504f, 4.23208611f, PAL_EPSILON * 10 }, // value: logf2(e) - { 1.57079633f, 4.81047738f, PAL_EPSILON * 10 }, // value: pi / 2 - { 2.30258509f, 10, PAL_EPSILON * 100 }, // value: ln(10) - { 2.71828183f, 15.1542622f, PAL_EPSILON * 100 }, // value: e - { 3.14159265f, 23.1406926f, PAL_EPSILON * 100 }, // value: pi - { PAL_POSINF, PAL_POSINF, 0 }, - }; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - expf_test1_validate(tests[i].value, tests[i].expected, tests[i].variance); - } - - expf_test1_validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/fabs/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/fabs/test1/test1.cpp deleted file mode 100644 index f3997dea01915b..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/fabs/test1/test1.cpp +++ /dev/null @@ -1,129 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that fabs return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** -**===========================================================================*/ - -#include - -// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (15-17 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use -// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx -// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will -// use PAL_EPSILON * 10. -#define PAL_EPSILON 8.8817841970012523e-16 - -#define PAL_NAN sqrt(-1.0) -#define PAL_POSINF -log(0.0) -#define PAL_NEGINF log(0.0) - -/** - * Helper test structure - */ -struct test -{ - double value; /* value to test the function with */ - double expected; /* expected result */ - double variance; /* maximum delta between the expected and actual result */ -}; - -/** - * fabs_test1_validate - * - * test validation function - */ -void __cdecl fabs_test1_validate(double value, double expected, double variance) -{ - double result = fabs(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - double delta = fabs(result - expected); - - if (delta > variance) - { - Fail("fabs(%g) returned %20.17g when it should have returned %20.17g", - value, result, expected); - } -} - -/** - * fabs_test1_validate - * - * test validation function for values returning NaN - */ -void __cdecl fabs_test1_validate_isnan(double value) -{ - double result = fabs(value); - - if (!_isnan(result)) - { - Fail("fabs(%g) returned %20.17g when it should have returned %20.17g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -PALTEST(c_runtime_fabs_test1_paltest_fabs_test1, "c_runtime/fabs/test1/paltest_fabs_test1") -{ - struct test tests[] = - { - /* value expected variance */ - { PAL_NEGINF, PAL_POSINF, 0 }, - { -3.1415926535897932, 3.1415926535897932, PAL_EPSILON * 10 }, // value: -(pi) expected: pi - { -2.7182818284590452, 2.7182818284590452, PAL_EPSILON * 10 }, // value: -(e) expected: e - { -2.3025850929940457, 2.3025850929940457, PAL_EPSILON * 10 }, // value: -(ln(10)) expected: ln(10) - { -1.5707963267948966, 1.5707963267948966, PAL_EPSILON * 10 }, // value: -(pi / 2) expected: pi / 2 - { -1.4426950408889634, 1.4426950408889634, PAL_EPSILON * 10 }, // value: -(log2(e)) expected: log2(e) - { -1.4142135623730950, 1.4142135623730950, PAL_EPSILON * 10 }, // value: -(sqrt(2)) expected: sqrt(2) - { -1.1283791670955126, 1.1283791670955126, PAL_EPSILON * 10 }, // value: -(2 / sqrt(pi)) expected: 2 / sqrt(pi) - { -1, 1, PAL_EPSILON * 10 }, - { -0.78539816339744831, 0.78539816339744831, PAL_EPSILON }, // value: -(pi / 4) expected: pi / 4 - { -0.70710678118654752, 0.70710678118654752, PAL_EPSILON }, // value: -(1 / sqrt(2)) expected: 1 / sqrt(2) - { -0.69314718055994531, 0.69314718055994531, PAL_EPSILON }, // value: -(ln(2)) expected: ln(2) - { -0.63661977236758134, 0.63661977236758134, PAL_EPSILON }, // value: -(2 / pi) expected: 2 / pi - { -0.43429448190325183, 0.43429448190325183, PAL_EPSILON }, // value: -(log10(e)) expected: log10(e) - { -0.31830988618379067, 0.31830988618379067, PAL_EPSILON }, // value: -(1 / pi) expected: 1 / pi - { -0.0, 0, PAL_EPSILON }, - }; - - - // PAL initialization - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - fabs_test1_validate( tests[i].value, tests[i].expected, tests[i].variance); - fabs_test1_validate(-tests[i].value, tests[i].expected, tests[i].variance); - } - - fabs_test1_validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/fabsf/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/fabsf/test1/test1.cpp deleted file mode 100644 index 68481ca97cef5a..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/fabsf/test1/test1.cpp +++ /dev/null @@ -1,129 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that fabsf return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** -**===========================================================================*/ - -#include - -// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (6-9 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON -// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use -// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10. -#define PAL_EPSILON 4.76837158e-07 - - -#define PAL_NAN sqrt(-1.0) -#define PAL_POSINF -log(0.0) -#define PAL_NEGINF log(0.0) - -/** - * Helper test structure - */ -struct test -{ - float value; /* value to test the function with */ - float expected; /* expected result */ - float variance; /* maximum delta between the expected and actual result */ -}; - -/** - * fabsf_test1_validate - * - * test validation function - */ -void __cdecl fabsf_test1_validate(float value, float expected, float variance) -{ - float result = fabsf(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - float delta = fabsf(result - expected); - - if (delta > variance) - { - Fail("fabsf(%g) returned %10.9g when it should have returned %10.9g", - value, result, expected); - } -} - -/** - * fabsf_test1_validate - * - * test validation function for values returning NaN - */ -void __cdecl fabsf_test1_validate_isnan(float value) -{ - float result = fabsf(value); - - if (!_isnan(result)) - { - Fail("fabsf(%g) returned %10.9g when it should have returned %10.9g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -PALTEST(c_runtime_fabsf_test1_paltest_fabsf_test1, "c_runtime/fabsf/test1/paltest_fabsf_test1") -{ - struct test tests[] = - { - /* value expected variance */ - { PAL_NEGINF, PAL_POSINF, 0 }, - { -3.14159265f, 3.14159265f, PAL_EPSILON * 10 }, // value: -(pi) expected: pi - { -2.71828183f, 2.71828183f, PAL_EPSILON * 10 }, // value: -(e) expected: e - { -2.30258509f, 2.30258509f, PAL_EPSILON * 10 }, // value: -(ln(10)) expected: ln(10) - { -1.57079633f, 1.57079633f, PAL_EPSILON * 10 }, // value: -(pi / 2) expected: pi / 2 - { -1.44269504f, 1.44269504f, PAL_EPSILON * 10 }, // value: -(log2(e)) expected: log2(e) - { -1.41421356f, 1.41421356f, PAL_EPSILON * 10 }, // value: -(sqrt(2)) expected: sqrt(2) - { -1.12837917f, 1.12837917f, PAL_EPSILON * 10 }, // value: -(2 / sqrt(pi)) expected: 2 / sqrt(pi) - { -1, 1, PAL_EPSILON * 10 }, - { -0.785398163f, 0.785398163f, PAL_EPSILON }, // value: -(pi / 4) expected: pi / 4 - { -0.707106781f, 0.707106781f, PAL_EPSILON }, // value: -(1 / sqrt(2)) expected: 1 / sqrt(2) - { -0.693147181f, 0.693147181f, PAL_EPSILON }, // value: -(ln(2)) expected: ln(2) - { -0.636619772f, 0.636619772f, PAL_EPSILON }, // value: -(2 / pi) expected: 2 / pi - { -0.434294482f, 0.434294482f, PAL_EPSILON }, // value: -(log10(e)) expected: log10(e) - { -0.318309886f, 0.318309886f, PAL_EPSILON }, // value: -(1 / pi) expected: 1 / pi - { -0.0f, 0, PAL_EPSILON }, - }; - - - // PAL initialization - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - fabsf_test1_validate( tests[i].value, tests[i].expected, tests[i].variance); - fabsf_test1_validate(-tests[i].value, tests[i].expected, tests[i].variance); - } - - fabsf_test1_validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/floor/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/floor/test1/test1.cpp deleted file mode 100644 index 549a2d83a0de56..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/floor/test1/test1.cpp +++ /dev/null @@ -1,131 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Tests floor with simple positive and negative values. Also tests -** extreme cases like extremely small values and positive and -** negative infinity. Makes sure that calling floor on NaN returns -** NaN -** -**==========================================================================*/ - -#include - -// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (15-17 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use -// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx -// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will -// use PAL_EPSILON * 10. -#define PAL_EPSILON 8.8817841970012523e-16 - -#define PAL_NAN sqrt(-1.0) -#define PAL_POSINF -log(0.0) -#define PAL_NEGINF log(0.0) - -/** - * Helper test structure - */ -struct test -{ - double value; /* value to test the function with */ - double expected; /* expected result */ - double variance; /* maximum delta between the expected and actual result */ -}; - -/** - * floor_test1_validate - * - * test validation function - */ -void __cdecl floor_test1_validate(double value, double expected, double variance) -{ - double result = floor(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - double delta = fabs(result - expected); - - if (delta > variance) - { - Fail("floor(%g) returned %20.17g when it should have returned %20.17g", - value, result, expected); - } -} - -/** - * floor_test1_validate - * - * test validation function for values returning NaN - */ -void __cdecl floor_test1_validate_isnan(double value) -{ - double result = floor(value); - - if (!_isnan(result)) - { - Fail("floor(%g) returned %20.17g when it should have returned %20.17g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -PALTEST(c_runtime_floor_test1_paltest_floor_test1, "c_runtime/floor/test1/paltest_floor_test1") -{ - struct test tests[] = - { - /* value expected variance */ - { 0.31830988618379067, 0, PAL_EPSILON }, // value: 1 / pi - { 0.43429448190325183, 0, PAL_EPSILON }, // value: log10(e) - { 0.63661977236758134, 0, PAL_EPSILON }, // value: 2 / pi - { 0.69314718055994531, 0, PAL_EPSILON }, // value: ln(2) - { 0.70710678118654752, 0, PAL_EPSILON }, // value: 1 / sqrt(2) - { 0.78539816339744831, 0, PAL_EPSILON }, // value: pi / 4 - { 1.1283791670955126, 1, PAL_EPSILON * 10 }, // value: 2 / sqrt(pi) - { 1.4142135623730950, 1, PAL_EPSILON * 10 }, // value: sqrt(2) - { 1.4426950408889634, 1, PAL_EPSILON * 10 }, // value: log2(e) - { 1.5707963267948966, 1, PAL_EPSILON * 10 }, // value: pi / 2 - { 2.3025850929940457, 2, PAL_EPSILON * 10 }, // value: ln(10) - { 2.7182818284590452, 2, PAL_EPSILON * 10 }, // value: e - { 3.1415926535897932, 3, PAL_EPSILON * 10 }, // value: pi - { PAL_POSINF, PAL_POSINF, 0 } - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - floor_test1_validate( 0, 0, PAL_EPSILON); - floor_test1_validate(-0.0, 0, PAL_EPSILON); - - floor_test1_validate( 1, 1, PAL_EPSILON * 10); - floor_test1_validate(-1.0, -1, PAL_EPSILON * 10); - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - floor_test1_validate( tests[i].value, tests[i].expected, tests[i].variance); - floor_test1_validate(-tests[i].value, -(tests[i].expected + 1), tests[i].variance); - } - - floor_test1_validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/floorf/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/floorf/test1/test1.cpp deleted file mode 100644 index b80320c7de317c..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/floorf/test1/test1.cpp +++ /dev/null @@ -1,130 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Tests floorf with simple positive and negative values. Also tests -** extreme cases like extremely small values and positive and -** negative infinity. Makes sure that calling floorf on NaN returns -** NaN -** -**==========================================================================*/ - -#include - -// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (6-9 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON -// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use -// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10. -#define PAL_EPSILON 4.76837158e-07 - -#define PAL_NAN sqrtf(-1.0f) -#define PAL_POSINF -logf(0.0f) -#define PAL_NEGINF logf(0.0f) - -/** - * Helper test structure - */ -struct test -{ - float value; /* value to test the function with */ - float expected; /* expected result */ - float variance; /* maximum delta between the expected and actual result */ -}; - -/** - * floorf_test1_validate - * - * test validation function - */ -void __cdecl floorf_test1_validate(float value, float expected, float variance) -{ - float result = floorf(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - float delta = fabsf(result - expected); - - if (delta > variance) - { - Fail("floorf(%g) returned %10.9g when it should have returned %10.9g", - value, result, expected); - } -} - -/** - * floorf_test1_validate - * - * test validation function for values returning NaN - */ -void __cdecl floorf_test1_validate_isnan(float value) -{ - float result = floorf(value); - - if (!_isnanf(result)) - { - Fail("floorf(%g) returned %10.9g when it should have returned %10.9g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -PALTEST(c_runtime_floorf_test1_paltest_floorf_test1, "c_runtime/floorf/test1/paltest_floorf_test1") -{ - struct test tests[] = - { - /* value expected variance */ - { 0.318309886f, 0, PAL_EPSILON }, // value: 1 / pi - { 0.434294482f, 0, PAL_EPSILON }, // value: log10f(e) - { 0.636619772f, 0, PAL_EPSILON }, // value: 2 / pi - { 0.693147181f, 0, PAL_EPSILON }, // value: ln(2) - { 0.707106781f, 0, PAL_EPSILON }, // value: 1 / sqrtf(2) - { 0.785398163f, 0, PAL_EPSILON }, // value: pi / 4 - { 1.12837917f, 1, PAL_EPSILON * 10 }, // value: 2 / sqrtf(pi) - { 1.41421356f, 1, PAL_EPSILON * 10 }, // value: sqrtf(2) - { 1.44269504f, 1, PAL_EPSILON * 10 }, // value: logf2(e) - { 1.57079633f, 1, PAL_EPSILON * 10 }, // value: pi / 2 - { 2.30258509f, 2, PAL_EPSILON * 10 }, // value: ln(10) - { 2.71828183f, 2, PAL_EPSILON * 10 }, // value: e - { 3.14159265f, 3, PAL_EPSILON * 10 }, // value: pi - { PAL_POSINF, PAL_POSINF, 0 } - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - floorf_test1_validate( 0, 0, PAL_EPSILON); - floorf_test1_validate(-0.0f, 0, PAL_EPSILON); - - floorf_test1_validate( 1, 1, PAL_EPSILON * 10); - floorf_test1_validate(-1.0f, -1, PAL_EPSILON * 10); - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - floorf_test1_validate( tests[i].value, tests[i].expected, tests[i].variance); - floorf_test1_validate(-tests[i].value, -(tests[i].expected + 1), tests[i].variance); - } - - floorf_test1_validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/fma/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/fma/test1/test1.cpp deleted file mode 100644 index a82adc4b6caa37..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/fma/test1/test1.cpp +++ /dev/null @@ -1,145 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Tests that fma returns correct values for a subset of values. -** Tests with positive and negative values of x, y, and z to ensure -** fmaf is returning correct results. -** -**===================================================================*/ - -#include - -// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (15-17 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use -// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx -// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will -// use PAL_EPSILON * 10. -#define PAL_EPSILON 8.8817841970012523e-16 - -#define PAL_NAN sqrt(-1.0) -#define PAL_POSINF -log(0.0) -#define PAL_NEGINF log(0.0) - -/** - * Helper test structure - */ -struct test -{ - double x; /* first component of the value to test the function with */ - double y; /* second component of the value to test the function with */ - double z; /* third component of the value to test the function with */ - double expected; /* expected result */ - double variance; /* maximum delta between the expected and actual result */ -}; - -/** - * fma_test1_validate - * - * test validation function - */ -void __cdecl fma_test1_validate(double x, double y, double z, double expected, double variance) -{ - double result = fma(x, y, z); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - double delta = fabs(result - expected); - - if (delta > variance) - { - Fail("fma(%g, %g, %g) returned %20.17g when it should have returned %20.17g", - x, y, z, result, expected); - } -} - -/** - * fma_test1_validate - * - * test validation function for values returning NaN - */ -void __cdecl fma_test1_validate_isnan(double x, double y, double z) -{ - double result = fma(x, y, z); - - if (!_isnan(result)) - { - Fail("fma(%g, %g, %g) returned %20.17g when it should have returned %20.17g", - x, y, z, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -PALTEST(c_runtime_fma_test1_paltest_fma_test1, "c_runtime/fma/test1/paltest_fma_test1") -{ - struct test tests[] = - { - /* x y z expected variance */ - { PAL_NEGINF, PAL_NEGINF, PAL_NEGINF, PAL_NEGINF, 0 }, - { -1e308, 2, 1e308, -1e308, 0 }, - { 1e308, 2, -1e308, 1e308, 0 }, - { PAL_POSINF, PAL_POSINF, PAL_POSINF, PAL_POSINF, 0 }, - }; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - fma_test1_validate(tests[i].x, tests[i].y, tests[i].z, tests[i].expected, tests[i].variance); - } - - // Returns NaN if x or y is infinite, the other is zero, and z is NaN - fma_test1_validate_isnan(PAL_NEGINF, 0, PAL_NAN); - fma_test1_validate_isnan(PAL_POSINF, 0, PAL_NAN); - fma_test1_validate_isnan(0, PAL_NEGINF, PAL_NAN); - fma_test1_validate_isnan(0, PAL_POSINF, PAL_NAN); - - // Returns NaN if x or y is infinite, the other is zero, and z is not-NaN - fma_test1_validate_isnan(PAL_POSINF, 0, PAL_NEGINF); - fma_test1_validate_isnan(PAL_NEGINF, 0, PAL_NEGINF); - fma_test1_validate_isnan(0, PAL_POSINF, PAL_NEGINF); - fma_test1_validate_isnan(0, PAL_NEGINF, PAL_NEGINF); - - fma_test1_validate_isnan(PAL_POSINF, 0, 0); - fma_test1_validate_isnan(PAL_NEGINF, 0, 0); - fma_test1_validate_isnan(0, PAL_POSINF, 0); - fma_test1_validate_isnan(0, PAL_NEGINF, 0); - - fma_test1_validate_isnan(PAL_POSINF, 0, PAL_POSINF); - fma_test1_validate_isnan(PAL_NEGINF, 0, PAL_POSINF); - fma_test1_validate_isnan(0, PAL_POSINF, PAL_POSINF); - fma_test1_validate_isnan(0, PAL_NEGINF, PAL_POSINF); - - // Returns NaN if (x * y) is infinite, and z is an infinite of the opposite sign - fma_test1_validate_isnan(PAL_POSINF, PAL_POSINF, PAL_NEGINF); - fma_test1_validate_isnan(PAL_NEGINF, PAL_NEGINF, PAL_NEGINF); - fma_test1_validate_isnan(PAL_POSINF, PAL_NEGINF, PAL_POSINF); - fma_test1_validate_isnan(PAL_NEGINF, PAL_POSINF, PAL_POSINF); - - fma_test1_validate_isnan(PAL_POSINF, 1, PAL_NEGINF); - fma_test1_validate_isnan(PAL_NEGINF, 1, PAL_POSINF); - fma_test1_validate_isnan(1, PAL_POSINF, PAL_NEGINF); - fma_test1_validate_isnan(1, PAL_NEGINF, PAL_POSINF); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/fmaf/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/fmaf/test1/test1.cpp deleted file mode 100644 index 10015a585118d6..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/fmaf/test1/test1.cpp +++ /dev/null @@ -1,144 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Tests that fmaf returns correct values for a subset of values. -** Tests with positive and negative values of x, y, and z to ensure -** fmaf is returning correct results. -** -**===================================================================*/ - -#include - -// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (6-9 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON -// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use -// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10. -#define PAL_EPSILON 4.76837158e-07 - -#define PAL_NAN sqrtf(-1.0f) -#define PAL_POSINF -logf(0.0f) -#define PAL_NEGINF logf(0.0f) - -/** - * Helper test structure - */ -struct test -{ - float x; /* first component of the value to test the function with */ - float y; /* second component of the value to test the function with */ - float z; /* third component of the value to test the function with */ - float expected; /* expected result */ - float variance; /* maximum delta between the expected and actual result */ -}; - -/** - * fmaf_test1_validate - * - * test validation function - */ -void __cdecl fmaf_test1_validate(float x, float y, float z, float expected, float variance) -{ - float result = fmaf(x, y, z); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - float delta = fabsf(result - expected); - - if (delta > variance) - { - Fail("fmaf(%g, %g, %g) returned %10.9g when it should have returned %10.9g", - x, y, z, result, expected); - } -} - -/** - * fmaf_test1_validate - * - * test validation function for values returning NaN - */ -void __cdecl fmaf_test1_validate_isnan(float x, float y, float z) -{ - float result = fmaf(x, y, z); - - if (!_isnanf(result)) - { - Fail("fmaf(%g, %g, %g) returned %10.9g when it should have returned %10.9g", - x, y, z, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -PALTEST(c_runtime_fmaf_test1_paltest_fmaf_test1, "c_runtime/fmaf/test1/paltest_fmaf_test1") -{ - struct test tests[] = - { - /* x y z expected variance */ - { PAL_NEGINF, PAL_NEGINF, PAL_NEGINF, PAL_NEGINF, 0 }, - { -1e38, 2, 1e38, -1e38, 0 }, - { 1e38, 2, -1e38, 1e38, 0 }, - { PAL_POSINF, PAL_POSINF, PAL_POSINF, PAL_POSINF, 0 }, - }; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - fmaf_test1_validate(tests[i].x, tests[i].y, tests[i].z, tests[i].expected, tests[i].variance); - } - - // Returns NaN if x or y is infinite, the other is zero, and z is NaN - fmaf_test1_validate_isnan(PAL_NEGINF, 0, PAL_NAN); - fmaf_test1_validate_isnan(PAL_POSINF, 0, PAL_NAN); - fmaf_test1_validate_isnan(0, PAL_NEGINF, PAL_NAN); - fmaf_test1_validate_isnan(0, PAL_POSINF, PAL_NAN); - - // Returns NaN if x or y is infinite, the other is zero, and z is not-NaN - fmaf_test1_validate_isnan(PAL_POSINF, 0, PAL_NEGINF); - fmaf_test1_validate_isnan(PAL_NEGINF, 0, PAL_NEGINF); - fmaf_test1_validate_isnan(0, PAL_POSINF, PAL_NEGINF); - fmaf_test1_validate_isnan(0, PAL_NEGINF, PAL_NEGINF); - - fmaf_test1_validate_isnan(PAL_POSINF, 0, 0); - fmaf_test1_validate_isnan(PAL_NEGINF, 0, 0); - fmaf_test1_validate_isnan(0, PAL_POSINF, 0); - fmaf_test1_validate_isnan(0, PAL_NEGINF, 0); - - fmaf_test1_validate_isnan(PAL_POSINF, 0, PAL_POSINF); - fmaf_test1_validate_isnan(PAL_NEGINF, 0, PAL_POSINF); - fmaf_test1_validate_isnan(0, PAL_POSINF, PAL_POSINF); - fmaf_test1_validate_isnan(0, PAL_NEGINF, PAL_POSINF); - - // Returns NaN if (x * y) is infinite, and z is an infinite of the opposite sign - fmaf_test1_validate_isnan(PAL_POSINF, PAL_POSINF, PAL_NEGINF); - fmaf_test1_validate_isnan(PAL_NEGINF, PAL_NEGINF, PAL_NEGINF); - fmaf_test1_validate_isnan(PAL_POSINF, PAL_NEGINF, PAL_POSINF); - fmaf_test1_validate_isnan(PAL_NEGINF, PAL_POSINF, PAL_POSINF); - - fmaf_test1_validate_isnan(PAL_POSINF, 1, PAL_NEGINF); - fmaf_test1_validate_isnan(PAL_NEGINF, 1, PAL_POSINF); - fmaf_test1_validate_isnan(1, PAL_POSINF, PAL_NEGINF); - fmaf_test1_validate_isnan(1, PAL_NEGINF, PAL_POSINF); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/fmod/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/fmod/test1/test1.cpp deleted file mode 100644 index d02b09d0e0d0ef..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/fmod/test1/test1.cpp +++ /dev/null @@ -1,156 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that fmod return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabs -** -**===========================================================================*/ - -#include - -// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (15-17 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use -// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx -// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will -// use PAL_EPSILON * 10. -#define PAL_EPSILON 8.8817841970012523e-16 - -#define PAL_NAN sqrt(-1.0) -#define PAL_POSINF -log(0.0) -#define PAL_NEGINF log(0.0) - -/** - * Helper test structure - */ -struct test -{ - double numerator; /* second component of the value to test the function with */ - double denominator; /* first component of the value to test the function with */ - double expected; /* expected result */ - double variance; /* maximum delta between the expected and actual result */ -}; - -/** - * fmod_test1_validate - * - * test validation function - */ -void __cdecl fmod_test1_validate(double numerator, double denominator, double expected, double variance) -{ - double result = fmod(numerator, denominator); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - double delta = fabs(result - expected); - - if (delta > variance) - { - Fail("fmod(%g, %g) returned %20.17g when it should have returned %20.17g", - numerator, denominator, result, expected); - } -} - -/** - * fmod_test1_validate - * - * test validation function for values returning NaN - */ -void __cdecl fmod_test1_validate_isnan(double numerator, double denominator) -{ - double result = fmod(numerator, denominator); - - if (!_isnan(result)) - { - Fail("fmod(%g, %g) returned %20.17g when it should have returned %20.17g", - numerator, denominator, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -PALTEST(c_runtime_fmod_test1_paltest_fmod_test1, "c_runtime/fmod/test1/paltest_fmod_test1") -{ - struct test tests[] = - { - /* numerator denominator expected variance */ - { 0, PAL_POSINF, 0, PAL_EPSILON }, - { 0.31296179620778659, 0.94976571538163866, 0.31296179620778658, PAL_EPSILON }, - { 0.42077048331375735, 0.90716712923909839, 0.42077048331375733, PAL_EPSILON }, - { 0.59448076852482208, 0.80410982822879171, 0.59448076852482212, PAL_EPSILON }, - { 0.63896127631363480, 0.76923890136397213, 0.63896127631363475, PAL_EPSILON }, - { 0.64963693908006244, 0.76024459707563015, 0.64963693908006248, PAL_EPSILON }, - { 0.70710678118654752, 0.70710678118654752, 0, PAL_EPSILON }, - { 1, 1, 0, PAL_EPSILON }, - { 0.84147098480789651, 0.54030230586813972, 0.30116867893975674, PAL_EPSILON }, - { 0.90371945743584630, 0.42812514788535792, 0.047469161665130377, PAL_EPSILON / 10 }, - { 0.98776594599273553, 0.15594369476537447, 0.052103777400488605, PAL_EPSILON / 10 }, - { 0.99180624439366372, 0.12775121753523991, 0.097547721646984359, PAL_EPSILON / 10 }, - { 0.74398033695749319, -0.66820151019031295, 0.075778826767180285, PAL_EPSILON / 10 }, - { 0.41078129050290870, -0.91173391478696510, 0.41078129050290868, PAL_EPSILON }, - { 0, -1, 0, PAL_EPSILON }, - { 1, PAL_POSINF, 1, PAL_EPSILON * 10 }, - }; - - - // PAL initialization - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - fmod_test1_validate( tests[i].numerator, tests[i].denominator, tests[i].expected, tests[i].variance); - fmod_test1_validate(-tests[i].numerator, tests[i].denominator, -tests[i].expected, tests[i].variance); - fmod_test1_validate( tests[i].numerator, -tests[i].denominator, tests[i].expected, tests[i].variance); - fmod_test1_validate(-tests[i].numerator, -tests[i].denominator, -tests[i].expected, tests[i].variance); - } - - fmod_test1_validate_isnan( 0, 0); - fmod_test1_validate_isnan(-0.0, 0); - fmod_test1_validate_isnan( 0, -0.0); - fmod_test1_validate_isnan(-0.0, -0.0); - - fmod_test1_validate_isnan( 1, 0); - fmod_test1_validate_isnan(-1.0, 0); - fmod_test1_validate_isnan( 1, -0.0); - fmod_test1_validate_isnan(-1.0, -0.0); - - fmod_test1_validate_isnan(PAL_POSINF, PAL_POSINF); - fmod_test1_validate_isnan(PAL_NEGINF, PAL_POSINF); - fmod_test1_validate_isnan(PAL_POSINF, PAL_NEGINF); - fmod_test1_validate_isnan(PAL_NEGINF, PAL_NEGINF); - - fmod_test1_validate_isnan(PAL_POSINF, 0); - fmod_test1_validate_isnan(PAL_NEGINF, 0); - fmod_test1_validate_isnan(PAL_POSINF, -0.0); - fmod_test1_validate_isnan(PAL_NEGINF, -0.0); - - fmod_test1_validate_isnan(PAL_POSINF, 1); - fmod_test1_validate_isnan(PAL_NEGINF, 1); - fmod_test1_validate_isnan(PAL_POSINF, -1.0); - fmod_test1_validate_isnan(PAL_NEGINF, -1.0); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/fmodf/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/fmodf/test1/test1.cpp deleted file mode 100644 index b73f7824f16686..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/fmodf/test1/test1.cpp +++ /dev/null @@ -1,155 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that fmodf return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabsf -** -**===========================================================================*/ - -#include - -// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (6-9 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON -// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use -// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10. -#define PAL_EPSILON 4.76837158e-07 - -#define PAL_NAN sqrt(-1.0) -#define PAL_POSINF -log(0.0) -#define PAL_NEGINF log(0.0) - -/** - * Helper test structure - */ -struct test -{ - float numerator; /* second component of the value to test the function with */ - float denominator; /* first component of the value to test the function with */ - float expected; /* expected result */ - float variance; /* maximum delta between the expected and actual result */ -}; - -/** - * fmodf_test1_validate - * - * test validation function - */ -void __cdecl fmodf_test1_validate(float numerator, float denominator, float expected, float variance) -{ - float result = fmodf(numerator, denominator); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - float delta = fabsf(result - expected); - - if (delta > variance) - { - Fail("fmodf(%g, %g) returned %10.9g when it should have returned %10.9g", - numerator, denominator, result, expected); - } -} - -/** - * fmodf_test1_validate - * - * test validation function for values returning NaN - */ -void __cdecl fmodf_test1_validate_isnan(float numerator, float denominator) -{ - float result = fmodf(numerator, denominator); - - if (!_isnan(result)) - { - Fail("fmodf(%g, %g) returned %10.9g when it should have returned %10.9g", - numerator, denominator, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -PALTEST(c_runtime_fmodf_test1_paltest_fmodf_test1, "c_runtime/fmodf/test1/paltest_fmodf_test1") -{ - struct test tests[] = - { - /* numerator denominator expected variance */ - { 0, PAL_POSINF, 0, PAL_EPSILON }, - { 0.312961796f, 0.949765715f, 0.312961796f, PAL_EPSILON }, - { 0.420770483f, 0.907167129f, 0.420770483f, PAL_EPSILON }, - { 0.594480769f, 0.804109828f, 0.594480769f, PAL_EPSILON }, - { 0.638961276f, 0.769238901f, 0.638961276f, PAL_EPSILON }, - { 0.649636939f, 0.760244597f, 0.649636939f, PAL_EPSILON }, - { 0.707106781f, 0.707106781f, 0, PAL_EPSILON }, - { 1, 1, 0, PAL_EPSILON }, - { 0.841470985f, 0.540302306f, 0.301168679f, PAL_EPSILON }, - { 0.903719457f, 0.428125148f, 0.0474691617f, PAL_EPSILON / 10 }, - { 0.987765946f, 0.155943695f, 0.0521037774f, PAL_EPSILON / 10 }, - { 0.991806244f, 0.127751218f, 0.0975477216f, PAL_EPSILON / 10 }, - { 0.743980337f, -0.668201510f, 0.0757788268f, PAL_EPSILON / 10 }, - { 0.410781291f, -0.911733915f, 0.410781291f, PAL_EPSILON }, - { 0, -1, 0, PAL_EPSILON }, - { 1, PAL_POSINF, 1, PAL_EPSILON * 10 }, - }; - - - // PAL initialization - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - fmodf_test1_validate( tests[i].numerator, tests[i].denominator, tests[i].expected, tests[i].variance); - fmodf_test1_validate(-tests[i].numerator, tests[i].denominator, -tests[i].expected, tests[i].variance); - fmodf_test1_validate( tests[i].numerator, -tests[i].denominator, tests[i].expected, tests[i].variance); - fmodf_test1_validate(-tests[i].numerator, -tests[i].denominator, -tests[i].expected, tests[i].variance); - } - - fmodf_test1_validate_isnan( 0, 0); - fmodf_test1_validate_isnan(-0.0f, 0); - fmodf_test1_validate_isnan( 0, -0.0f); - fmodf_test1_validate_isnan(-0.0f, -0.0f); - - fmodf_test1_validate_isnan( 1, 0); - fmodf_test1_validate_isnan(-1, 0); - fmodf_test1_validate_isnan( 1, -0.0f); - fmodf_test1_validate_isnan(-1, -0.0f); - - fmodf_test1_validate_isnan(PAL_POSINF, PAL_POSINF); - fmodf_test1_validate_isnan(PAL_NEGINF, PAL_POSINF); - fmodf_test1_validate_isnan(PAL_POSINF, PAL_NEGINF); - fmodf_test1_validate_isnan(PAL_NEGINF, PAL_NEGINF); - - fmodf_test1_validate_isnan(PAL_POSINF, 0); - fmodf_test1_validate_isnan(PAL_NEGINF, 0); - fmodf_test1_validate_isnan(PAL_POSINF, -0.0f); - fmodf_test1_validate_isnan(PAL_NEGINF, -0.0f); - - fmodf_test1_validate_isnan(PAL_POSINF, 1); - fmodf_test1_validate_isnan(PAL_NEGINF, 1); - fmodf_test1_validate_isnan(PAL_POSINF, -1); - fmodf_test1_validate_isnan(PAL_NEGINF, -1); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/ilogb/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/ilogb/test1/test1.cpp deleted file mode 100644 index 9fbd270d52579c..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/ilogb/test1/test1.cpp +++ /dev/null @@ -1,100 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Tests that ilogb returns correct values. -** -**===================================================================*/ - -#include - -#define PAL_NAN sqrt(-1.0) -#define PAL_POSINF -log(0.0) -#define PAL_NEGINF log(0.0) - -/** - * Helper test structure - */ -struct test -{ - double value; /* value to test the function with */ - int expected; /* expected result */ -}; - -/** - * ilogb_test1_validate - * - * test validation function - */ -void __cdecl ilogb_test1_validate(double value, int expected) -{ - int result = ilogb(value); - - if (result != expected) - { - Fail("ilogb(%g) returned %d when it should have returned %d", - value, result, expected); - } -} - -/** - * main - * - * executable entry point - */ -PALTEST(c_runtime_ilogb_test1_paltest_ilogb_test1, "c_runtime/ilogb/test1/paltest_ilogb_test1") -{ - struct test tests[] = - { - /* value expected */ - { PAL_NEGINF, 2147483647 }, - { 0, -2147483648 }, - { PAL_POSINF, 2147483647 }, - { 0.11331473229676087, -4 }, // expected: -(pi) - { 0.15195522325791297, -3 }, // expected: -(e) - { 0.20269956628651730, -3 }, // expected: -(ln(10)) - { 0.33662253682241906, -2 }, // expected: -(pi / 2) - { 0.36787944117144232, -2 }, // expected: -(log2(e)) - { 0.37521422724648177, -2 }, // expected: -(sqrt(2)) - { 0.45742934732229695, -2 }, // expected: -(2 / sqrt(pi)) - { 0.5, -1 }, // expected: -(1) - { 0.58019181037172444, -1 }, // expected: -(pi / 4) - { 0.61254732653606592, -1 }, // expected: -(1 / sqrt(2)) - { 0.61850313780157598, -1 }, // expected: -(ln(2)) - { 0.64321824193300488, -1 }, // expected: -(2 / pi) - { 0.74005557395545179, -1 }, // expected: -(log10(e)) - { 0.80200887896145195, -1 }, // expected: -(1 / pi) - { 1, 0 }, - { 1.2468689889006383, 0 }, // expected: 1 / pi - { 1.3512498725672678, 0 }, // expected: log10(e) - { 1.5546822754821001, 0 }, // expected: 2 / pi - { 1.6168066722416747, 0 }, // expected: ln(2) - { 1.6325269194381528, 0 }, // expected: 1 / sqrt(2) - { 1.7235679341273495, 0 }, // expected: pi / 4 - { 2, 1 }, - { 2.1861299583286618, 1 }, // expected: 2 / sqrt(pi) - { 2.6651441426902252, 1 }, // expected: sqrt(2) - { 2.7182818284590452, 1 }, // expected: log2(e) value: e - { 2.9706864235520193, 1 }, // expected: pi / 2 - { 4.9334096679145963, 2 }, // expected: ln(10) - { 6.5808859910179210, 2 }, // expected: e - { 8.8249778270762876, 3 }, // expected: pi - { PAL_NAN, 2147483647 }, - }; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - ilogb_test1_validate(tests[i].value, tests[i].expected); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/ilogbf/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/ilogbf/test1/test1.cpp deleted file mode 100644 index c5022056c97e42..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/ilogbf/test1/test1.cpp +++ /dev/null @@ -1,100 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Tests that ilogbf returns correct values. -** -**===================================================================*/ - -#include - -#define PAL_NAN sqrtf(-1.0f) -#define PAL_POSINF -logf(0.0f) -#define PAL_NEGINF logf(0.0f) - -/** - * Helper test structure - */ -struct test -{ - float value; /* value to test the function with */ - int expected; /* expected result */ -}; - -/** - * ilogbf_test1_validate - * - * test validation function - */ -void __cdecl ilogbf_test1_validate(float value, int expected) -{ - int result = ilogbf(value); - - if (result != expected) - { - Fail("ilogbf(%g) returned %d when it should have returned %d", - value, result, expected); - } -} - -/** - * main - * - * executable entry point - */ -PALTEST(c_runtime_ilogbf_test1_paltest_ilogbf_test1, "c_runtime/ilogbf/test1/paltest_ilogbf_test1") -{ - struct test tests[] = - { - /* value expected */ - { PAL_NEGINF, 2147483647 }, - { 0, -2147483648 }, - { PAL_POSINF, 2147483647 }, - { 0.113314732f, -4 }, // expected: -(pi) - { 0.151955223f, -3 }, // expected: -(e) - { 0.202699566f, -3 }, // expected: -(ln(10)) - { 0.336622537f, -2 }, // expected: -(pi / 2) - { 0.367879441f, -2 }, // expected: -(log2(e)) - { 0.375214227f, -2 }, // expected: -(sqrt(2)) - { 0.457429347f, -2 }, // expected: -(2 / sqrt(pi)) - { 0.5f, -1 }, // expected: -(1) - { 0.580191810f, -1 }, // expected: -(pi / 4) - { 0.612547327f, -1 }, // expected: -(1 / sqrt(2)) - { 0.618503138f, -1 }, // expected: -(ln(2)) - { 0.643218242f, -1 }, // expected: -(2 / pi) - { 0.740055574f, -1 }, // expected: -(log10(e)) - { 0.802008879f, -1 }, // expected: -(1 / pi) - { 1, 0 }, - { 1.24686899f, 0 }, // expected: 1 / pi - { 1.35124987f, 0 }, // expected: log10(e) - { 1.55468228f, 0 }, // expected: 2 / pi - { 1.61680667f, 0 }, // expected: ln(2) - { 1.63252692f, 0 }, // expected: 1 / sqrt(2) - { 1.72356793f, 0 }, // expected: pi / 4 - { 2, 1 }, - { 2.18612996f, 1 }, // expected: 2 / sqrt(pi) - { 2.66514414f, 1 }, // expected: sqrt(2) - { 2.71828183f, 1 }, // expected: log2(e) value: e - { 2.97068642f, 1 }, // expected: pi / 2 - { 4.93340967f, 2 }, // expected: ln(10) - { 6.58088599f, 2 }, // expected: e - { 8.82497783f, 3 }, // expected: pi - { PAL_NAN, 2147483647 }, - }; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - ilogbf_test1_validate(tests[i].value, tests[i].expected); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/log/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/log/test1/test1.cpp deleted file mode 100644 index a780558a049b8f..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/log/test1/test1.cpp +++ /dev/null @@ -1,139 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Tests log with a normal set of values. -** -**===================================================================*/ - -#include - -// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (15-17 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use -// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx -// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will -// use PAL_EPSILON * 10. -#define PAL_EPSILON 8.8817841970012523e-16 - -#define PAL_NAN sqrt(-1.0) -#define PAL_POSINF -log(0.0) -#define PAL_NEGINF log(0.0) - -/** - * Helper test structure - */ -struct test -{ - double value; /* value to test the function with */ - double expected; /* expected result */ - double variance; /* maximum delta between the expected and actual result */ -}; - -/** - * log_test1_validate - * - * test validation function - */ -void __cdecl log_test1_validate(double value, double expected, double variance) -{ - double result = log(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - double delta = fabs(result - expected); - - if (delta > variance) - { - Fail("log(%g) returned %20.17g when it should have returned %20.17g", - value, result, expected); - } -} - -/** - * log_test1_validate - * - * test validation function for values returning NaN - */ -void __cdecl log_test1_validate_isnan(double value) -{ - double result = log(value); - - if (!_isnan(result)) - { - Fail("log(%g) returned %20.17g when it should have returned %20.17g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -PALTEST(c_runtime_log_test1_paltest_log_test1, "c_runtime/log/test1/paltest_log_test1") -{ - struct test tests[] = - { - /* value expected variance */ - { 0, PAL_NEGINF, 0 }, - { 0.043213918263772250, -3.1415926535897932, PAL_EPSILON * 10 }, // expected: -(pi) - { 0.065988035845312537, -2.7182818284590452, PAL_EPSILON * 10 }, // expected: -(e) - { 0.1, -2.3025850929940457, PAL_EPSILON * 10 }, // expected: -(ln(10)) - { 0.20787957635076191, -1.5707963267948966, PAL_EPSILON * 10 }, // expected: -(pi / 2) - { 0.23629008834452270, -1.4426950408889634, PAL_EPSILON * 10 }, // expected: -(log2(e)) - { 0.24311673443421421, -1.4142135623730950, PAL_EPSILON * 10 }, // expected: -(sqrt(2)) - { 0.32355726390307110, -1.1283791670955126, PAL_EPSILON * 10 }, // expected: -(2 / sqrt(pi)) - { 0.36787944117144232, -1, PAL_EPSILON * 10 }, // expected: -(1) - { 0.45593812776599624, -0.78539816339744831, PAL_EPSILON }, // expected: -(pi / 4) - { 0.49306869139523979, -0.70710678118654752, PAL_EPSILON }, // expected: -(1 / sqrt(2)) - { 0.5, -0.69314718055994531, PAL_EPSILON }, // expected: -(ln(2)) - { 0.52907780826773535, -0.63661977236758134, PAL_EPSILON }, // expected: -(2 / pi) - { 0.64772148514180065, -0.43429448190325183, PAL_EPSILON }, // expected: -(log10(e)) - { 0.72737734929521647, -0.31830988618379067, PAL_EPSILON }, // expected: -(1 / pi) - { 1, 0, PAL_EPSILON }, - { 1.3748022274393586, 0.31830988618379067, PAL_EPSILON }, // expected: 1 / pi - { 1.5438734439711811, 0.43429448190325183, PAL_EPSILON }, // expected: log10(e) - { 1.8900811645722220, 0.63661977236758134, PAL_EPSILON }, // expected: 2 / pi - { 2, 0.69314718055994531, PAL_EPSILON }, // expected: ln(2) - { 2.0281149816474725, 0.70710678118654752, PAL_EPSILON }, // expected: 1 / sqrt(2) - { 2.1932800507380155, 0.78539816339744831, PAL_EPSILON }, // expected: pi / 4 - { 2.7182818284590452, 1, PAL_EPSILON * 10 }, // value: e - { 3.0906430223107976, 1.1283791670955126, PAL_EPSILON * 10 }, // expected: 2 / sqrt(pi) - { 4.1132503787829275, 1.4142135623730950, PAL_EPSILON * 10 }, // expected: sqrt(2) - { 4.2320861065570819, 1.4426950408889634, PAL_EPSILON * 10 }, // expected: log2(e) - { 4.8104773809653517, 1.5707963267948966, PAL_EPSILON * 10 }, // expected: pi / 2 - { 10, 2.3025850929940457, PAL_EPSILON * 10 }, // expected: ln(10) - { 15.154262241479264, 2.7182818284590452, PAL_EPSILON * 10 }, // expected: e - { 23.140692632779269, 3.1415926535897932, PAL_EPSILON * 10 }, // expected: pi - { PAL_POSINF, PAL_POSINF, 0 }, - }; - - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - log_test1_validate(tests[i].value, tests[i].expected, tests[i].variance); - } - - log_test1_validate_isnan(PAL_NEGINF); - log_test1_validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/log10/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/log10/test1/test1.cpp deleted file mode 100644 index 26d13508cc4b70..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/log10/test1/test1.cpp +++ /dev/null @@ -1,145 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that log10 returns correct values. -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabs -** _isnan -** -**===========================================================================*/ - -#include - -// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (15-17 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use -// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx -// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will -// use PAL_EPSILON * 10. -#define PAL_EPSILON 8.8817841970012523e-16 - -#define PAL_NAN sqrt(-1.0) -#define PAL_POSINF -log(0.0) -#define PAL_NEGINF log(0.0) - -/** - * Helper test structure - */ -struct test -{ - double value; /* value to test the function with */ - double expected; /* expected result */ - double variance; /* maximum delta between the expected and actual result */ -}; - -/** - * log10_test1_validate - * - * test validation function - */ -void __cdecl log10_test1_validate(double value, double expected, double variance) -{ - double result = log10(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - double delta = fabs(result - expected); - - if (delta > variance) - { - Fail("log10(%g) returned %20.17g when it should have returned %20.17g", - value, result, expected); - } -} - -/** - * log10_test1_validate - * - * test validation function for values returning NaN - */ -void __cdecl log10_test1_validate_isnan(double value) -{ - double result = log10(value); - - if (!_isnan(result)) - { - Fail("log10(%g) returned %20.17g when it should have returned %20.17g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -PALTEST(c_runtime_log10_test1_paltest_log10_test1, "c_runtime/log10/test1/paltest_log10_test1") -{ - struct test tests[] = - { - /* value expected variance */ - { 0, PAL_NEGINF, 0 }, - { 0.00072178415907472774, -3.1415926535897932, PAL_EPSILON * 10 }, // expected: -(pi) - { 0.0019130141022243176, -2.7182818284590452, PAL_EPSILON * 10 }, // expected: -(e) - { 0.0049821282964407206, -2.3025850929940457, PAL_EPSILON * 10 }, // expected: -(ln(10)) - { 0.026866041001136132, -1.5707963267948966, PAL_EPSILON * 10 }, // expected: -(pi / 2) - { 0.036083192820787210, -1.4426950408889634, PAL_EPSILON * 10 }, // expected: -(log2(e)) - { 0.038528884700322026, -1.4142135623730950, PAL_EPSILON * 10 }, // expected: -(sqrt(2)) - { 0.074408205860642723, -1.1283791670955126, PAL_EPSILON * 10 }, // expected: -(2 / sqrt(pi)) - { 0.1, -1, PAL_EPSILON * 10 }, // expected: -(1) - { 0.16390863613957665, -0.78539816339744831, PAL_EPSILON }, // expected: -(pi / 4) - { 0.19628775993505562, -0.70710678118654752, PAL_EPSILON }, // expected: -(1 / sqrt(2)) - { 0.20269956628651730, -0.69314718055994531, PAL_EPSILON }, // expected: -(ln(2)) - { 0.23087676451600055, -0.63661977236758134, PAL_EPSILON }, // expected: -(2 / pi) - { 0.36787944117144232, -0.43429448190325183, PAL_EPSILON }, // expected: -(log10(e)) - { 0.48049637305186868, -0.31830988618379067, PAL_EPSILON }, // expected: -(1 / pi) - { 1, 0, PAL_EPSILON }, - { 2.0811811619898573, 0.31830988618379067, PAL_EPSILON }, // expected: 1 / pi - { 2.7182818284590452, 0.43429448190325183, PAL_EPSILON }, // expected: log10(e) value: e - { 4.3313150290214525, 0.63661977236758134, PAL_EPSILON }, // expected: 2 / pi - { 4.9334096679145963, 0.69314718055994531, PAL_EPSILON }, // expected: ln(2) - { 5.0945611704512962, 0.70710678118654752, PAL_EPSILON }, // expected: 1 / sqrt(2) - { 6.1009598002416937, 0.78539816339744831, PAL_EPSILON }, // expected: pi / 4 - { 10, 1, PAL_EPSILON * 10 }, - { 13.439377934644400, 1.1283791670955126, PAL_EPSILON * 10 }, // expected: 2 / sqrt(pi) - { 25.954553519470081, 1.4142135623730950, PAL_EPSILON * 10 }, // expected: sqrt(2) - { 27.713733786437790, 1.4426950408889634, PAL_EPSILON * 10 }, // expected: log2(e) - { 37.221710484165167, 1.5707963267948966, PAL_EPSILON * 10 }, // expected: pi / 2 - { 200.71743249053009, 2.3025850929940457, PAL_EPSILON * 10 }, // expected: ln(10) - { 522.73529967043665, 2.7182818284590452, PAL_EPSILON * 10 }, // expected: e - { 1385.4557313670111, 3.1415926535897932, PAL_EPSILON * 10 }, // expected: pi - { PAL_POSINF, PAL_POSINF, 0 }, - }; - - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - log10_test1_validate(tests[i].value, tests[i].expected, tests[i].variance); - } - - log10_test1_validate_isnan(PAL_NEGINF); - log10_test1_validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/log10f/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/log10f/test1/test1.cpp deleted file mode 100644 index a503ebaab744da..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/log10f/test1/test1.cpp +++ /dev/null @@ -1,143 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that log10f returns correct values. -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabs -** _isnanf -** -**===========================================================================*/ - -#include - -// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (6-9 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON -// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use -// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10. -#define PAL_EPSILON 4.76837158e-07 - -#define PAL_NAN sqrtf(-1.0f) -#define PAL_POSINF -logf(0.0f) -#define PAL_NEGINF logf(0.0f) - -/** - * Helper test structure - */ -struct test -{ - float value; /* value to test the function with */ - float expected; /* expected result */ - float variance; /* maximum delta between the expected and actual result */ -}; - -/** - * log10f_test1_validate - * - * test validation function - */ -void __cdecl log10f_test1_validate(float value, float expected, float variance) -{ - float result = log10f(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - float delta = fabsf(result - expected); - - if (delta > variance) - { - Fail("log10f(%g) returned %10.9g when it should have returned %10.9g", - value, result, expected); - } -} - -/** - * log10f_test1_validate - * - * test validation function for values returning NaN - */ -void __cdecl log10f_test1_validate_isnan(float value) -{ - float result = log10f(value); - - if (!_isnanf(result)) - { - Fail("log10f(%g) returned %10.9g when it should have returned %10.9g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -PALTEST(c_runtime_log10f_test1_paltest_log10f_test1, "c_runtime/log10f/test1/paltest_log10f_test1") -{ - struct test tests[] = - { - /* value expected variance */ - { 0, PAL_NEGINF, 0 }, - { 0.000721784159f, -3.14159265f, PAL_EPSILON * 10 }, // expected: -(pi) - { 0.00191301410f, -2.71828183f, PAL_EPSILON * 10 }, // expected: -(e) - { 0.00498212830f, -2.30258509f, PAL_EPSILON * 10 }, // expected: -(ln(10)) - { 0.0268660410f, -1.57079633f, PAL_EPSILON * 10 }, // expected: -(pi / 2) - { 0.0360831928f, -1.44269504f, PAL_EPSILON * 10 }, // expected: -(logf2(e)) - { 0.0385288847f, -1.41421356f, PAL_EPSILON * 10 }, // expected: -(sqrtf(2)) - { 0.0744082059f, -1.12837917f, PAL_EPSILON * 10 }, // expected: -(2 / sqrtf(pi)) - { 0.1f, -1, PAL_EPSILON * 10 }, // expected: -(1) - { 0.163908636f, -0.785398163f, PAL_EPSILON }, // expected: -(pi / 4) - { 0.196287760f, -0.707106781f, PAL_EPSILON }, // expected: -(1 / sqrtf(2)) - { 0.202699566f, -0.693147181f, PAL_EPSILON }, // expected: -(ln(2)) - { 0.230876765f, -0.636619772f, PAL_EPSILON }, // expected: -(2 / pi) - { 0.367879441f, -0.434294482f, PAL_EPSILON }, // expected: -(log10f(e)) - { 0.480496373f, -0.318309886f, PAL_EPSILON }, // expected: -(1 / pi) - { 1, 0, PAL_EPSILON }, - { 2.08118116f, 0.318309886f, PAL_EPSILON }, // expected: 1 / pi - { 2.71828183f, 0.434294482f, PAL_EPSILON }, // expected: log10f(e) value: e - { 4.33131503f, 0.636619772f, PAL_EPSILON }, // expected: 2 / pi - { 4.93340967f, 0.693147181f, PAL_EPSILON }, // expected: ln(2) - { 5.09456117f, 0.707106781f, PAL_EPSILON }, // expected: 1 / sqrtf(2) - { 6.10095980f, 0.785398163f, PAL_EPSILON }, // expected: pi / 4 - { 10, 1, PAL_EPSILON * 10 }, - { 13.4393779f, 1.12837917f, PAL_EPSILON * 10 }, // expected: 2 / sqrtf(pi) - { 25.9545535f, 1.41421356f, PAL_EPSILON * 10 }, // expected: sqrtf(2) - { 27.7137338f, 1.44269504f, PAL_EPSILON * 10 }, // expected: logf2(e) - { 37.2217105f, 1.57079633f, PAL_EPSILON * 10 }, // expected: pi / 2 - { 200.717432f, 2.30258509f, PAL_EPSILON * 10 }, // expected: ln(10) - { 522.735300f, 2.71828183f, PAL_EPSILON * 10 }, // expected: e - { 1385.45573f, 3.14159265f, PAL_EPSILON * 10 }, // expected: pi - { PAL_POSINF, PAL_POSINF, 0 }, - }; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - log10f_test1_validate(tests[i].value, tests[i].expected, tests[i].variance); - } - - log10f_test1_validate_isnan(PAL_NEGINF); - log10f_test1_validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/log2/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/log2/test1/test1.cpp deleted file mode 100644 index 8ca12f4dd54c9e..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/log2/test1/test1.cpp +++ /dev/null @@ -1,138 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Tests that log2 returns correct values. -** -**===================================================================*/ - -#include - -// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (15-17 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use -// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx -// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will -// use PAL_EPSILON * 10. -#define PAL_EPSILON 8.8817841970012523e-16 - -#define PAL_NAN sqrt(-1.0) -#define PAL_POSINF -log(0.0) -#define PAL_NEGINF log(0.0) - -/** - * Helper test structure - */ -struct test -{ - double value; /* value to test the function with */ - double expected; /* expected result */ - double variance; /* maximum delta between the expected and actual result */ -}; - -/** - * log2_test1_validate - * - * test validation function - */ -void __cdecl log2_test1_validate(double value, double expected, double variance) -{ - double result = log2(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - double delta = fabs(result - expected); - - if (delta > variance) - { - Fail("log2(%g) returned %20.17g when it should have returned %20.17g", - value, result, expected); - } -} - -/** - * log2_test1_validate - * - * test validation function for values returning NaN - */ -void __cdecl log2_test1_validate_isnan(double value) -{ - double result = log2(value); - - if (!_isnan(result)) - { - Fail("log2(%g) returned %20.17g when it should have returned %20.17g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -PALTEST(c_runtime_log2_test1_paltest_log2_test1, "c_runtime/log2/test1/paltest_log2_test1") -{ - struct test tests[] = - { - /* value expected variance */ - { 0, PAL_NEGINF, 0 }, - { 0.11331473229676087, -3.1415926535897932, PAL_EPSILON * 10 }, // expected: -(pi) - { 0.15195522325791297, -2.7182818284590452, PAL_EPSILON * 10 }, // expected: -(e) - { 0.20269956628651730, -2.3025850929940457, PAL_EPSILON * 10 }, // expected: -(ln(10)) - { 0.33662253682241906, -1.5707963267948966, PAL_EPSILON * 10 }, // expected: -(pi / 2) - { 0.36787944117144232, -1.4426950408889634, PAL_EPSILON * 10 }, // expected: -(log2(e)) - { 0.37521422724648177, -1.4142135623730950, PAL_EPSILON * 10 }, // expected: -(sqrt(2)) - { 0.45742934732229695, -1.1283791670955126, PAL_EPSILON * 10 }, // expected: -(2 / sqrt(pi)) - { 0.5, -1, PAL_EPSILON * 10 }, // expected: -(1) - { 0.58019181037172444, -0.78539816339744831, PAL_EPSILON }, // expected: -(pi / 4) - { 0.61254732653606592, -0.70710678118654752, PAL_EPSILON }, // expected: -(1 / sqrt(2)) - { 0.61850313780157598, -0.69314718055994531, PAL_EPSILON }, // expected: -(ln(2)) - { 0.64321824193300488, -0.63661977236758134, PAL_EPSILON }, // expected: -(2 / pi) - { 0.74005557395545179, -0.43429448190325183, PAL_EPSILON }, // expected: -(log10(e)) - { 0.80200887896145195, -0.31830988618379067, PAL_EPSILON }, // expected: -(1 / pi) - { 1, 0, PAL_EPSILON }, - { 1.2468689889006383, 0.31830988618379067, PAL_EPSILON }, // expected: 1 / pi - { 1.3512498725672678, 0.43429448190325183, PAL_EPSILON }, // expected: log10(e) - { 1.5546822754821001, 0.63661977236758134, PAL_EPSILON }, // expected: 2 / pi - { 1.6168066722416747, 0.69314718055994531, PAL_EPSILON }, // expected: ln(2) - { 1.6325269194381528, 0.70710678118654752, PAL_EPSILON }, // expected: 1 / sqrt(2) - { 1.7235679341273495, 0.78539816339744831, PAL_EPSILON }, // expected: pi / 4 - { 2, 1, PAL_EPSILON * 10 }, - { 2.1861299583286618, 1.1283791670955126, PAL_EPSILON * 10 }, // expected: 2 / sqrt(pi) - { 2.6651441426902252, 1.4142135623730950, PAL_EPSILON * 10 }, // expected: sqrt(2) - { 2.7182818284590452, 1.4426950408889634, PAL_EPSILON * 10 }, // expected: log2(e) value: e - { 2.9706864235520193, 1.5707963267948966, PAL_EPSILON * 10 }, // expected: pi / 2 - { 4.9334096679145963, 2.3025850929940457, PAL_EPSILON * 10 }, // expected: ln(10) - { 6.5808859910179210, 2.7182818284590452, PAL_EPSILON * 10 }, // expected: e - { 8.8249778270762876, 3.1415926535897932, PAL_EPSILON * 10 }, // expected: pi - { PAL_POSINF, PAL_POSINF, 0 }, - }; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - log2_test1_validate(tests[i].value, tests[i].expected, tests[i].variance); - } - - log2_test1_validate_isnan(PAL_NEGINF); - log2_test1_validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/log2f/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/log2f/test1/test1.cpp deleted file mode 100644 index 29de3c76de7946..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/log2f/test1/test1.cpp +++ /dev/null @@ -1,137 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Tests that log2f returns correct values. -** -**===================================================================*/ - -#include - -// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (6-9 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON -// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use -// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10. -#define PAL_EPSILON 4.76837158e-07 - -#define PAL_NAN sqrtf(-1.0f) -#define PAL_POSINF -logf(0.0f) -#define PAL_NEGINF logf(0.0f) - -/** - * Helper test structure - */ -struct test -{ - float value; /* value to test the function with */ - float expected; /* expected result */ - float variance; /* maximum delta between the expected and actual result */ -}; - -/** - * log2f_test1_validate - * - * test validation function - */ -void __cdecl log2f_test1_validate(float value, float expected, float variance) -{ - float result = log2f(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - float delta = fabsf(result - expected); - - if (delta > variance) - { - Fail("log2f(%g) returned %10.9g when it should have returned %10.9g", - value, result, expected); - } -} - -/** - * log2f_test1_validate - * - * test validation function for values returning NaN - */ -void __cdecl log2f_test1_validate_isnan(float value) -{ - float result = log2f(value); - - if (!_isnanf(result)) - { - Fail("log2f(%g) returned %10.9g when it should have returned %10.9g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -PALTEST(c_runtime_log2f_test1_paltest_log2f_test1, "c_runtime/log2f/test1/paltest_log2f_test1") -{ - struct test tests[] = - { - /* value expected variance */ - { 0, PAL_NEGINF, 0 }, - { 0.113314732f, -3.14159265f, PAL_EPSILON * 10 }, // expected: -(pi) - { 0.151955223f, -2.71828183f, PAL_EPSILON * 10 }, // expected: -(e) - { 0.202699566f, -2.30258509f, PAL_EPSILON * 10 }, // expected: -(ln(10)) - { 0.336622537f, -1.57079633f, PAL_EPSILON * 10 }, // expected: -(pi / 2) - { 0.367879441f, -1.44269504f, PAL_EPSILON * 10 }, // expected: -(logf2(e)) - { 0.375214227f, -1.41421356f, PAL_EPSILON * 10 }, // expected: -(sqrtf(2)) - { 0.457429347f, -1.12837917f, PAL_EPSILON * 10 }, // expected: -(2 / sqrtf(pi)) - { 0.5f, -1, PAL_EPSILON * 10 }, // expected: -(1) - { 0.580191810f, -0.785398163f, PAL_EPSILON }, // expected: -(pi / 4) - { 0.612547327f, -0.707106781f, PAL_EPSILON }, // expected: -(1 / sqrtf(2)) - { 0.618503138f, -0.693147181f, PAL_EPSILON }, // expected: -(ln(2)) - { 0.643218242f, -0.636619772f, PAL_EPSILON }, // expected: -(2 / pi) - { 0.740055574f, -0.434294482f, PAL_EPSILON }, // expected: -(log10f(e)) - { 0.802008879f, -0.318309886f, PAL_EPSILON }, // expected: -(1 / pi) - { 1, 0, PAL_EPSILON }, - { 1.24686899f, 0.318309886f, PAL_EPSILON }, // expected: 1 / pi - { 1.35124987f, 0.434294482f, PAL_EPSILON }, // expected: log10f(e) value: e - { 1.55468228f, 0.636619772f, PAL_EPSILON }, // expected: 2 / pi - { 1.61680667f, 0.693147181f, PAL_EPSILON }, // expected: ln(2) - { 1.63252692f, 0.707106781f, PAL_EPSILON }, // expected: 1 / sqrtf(2) - { 1.72356793f, 0.785398163f, PAL_EPSILON }, // expected: pi / 4 - { 2, 1, PAL_EPSILON * 10 }, - { 2.18612996f, 1.12837917f, PAL_EPSILON * 10 }, // expected: 2 / sqrtf(pi) - { 2.66514414f, 1.41421356f, PAL_EPSILON * 10 }, // expected: sqrtf(2) - { 2.71828183f, 1.44269504f, PAL_EPSILON * 10 }, // expected: logf2(e) - { 2.97068642f, 1.57079633f, PAL_EPSILON * 10 }, // expected: pi / 2 - { 4.93340967f, 2.30258509f, PAL_EPSILON * 10 }, // expected: ln(10) - { 6.58088599f, 2.71828183f, PAL_EPSILON * 10 }, // expected: e - { 8.82497783f, 3.14159265f, PAL_EPSILON * 10 }, // expected: pi - { PAL_POSINF, PAL_POSINF, 0 }, - }; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - log2f_test1_validate(tests[i].value, tests[i].expected, tests[i].variance); - } - - log2f_test1_validate_isnan(PAL_NEGINF); - log2f_test1_validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/logf/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/logf/test1/test1.cpp deleted file mode 100644 index 7980ae1b28e9e1..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/logf/test1/test1.cpp +++ /dev/null @@ -1,138 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Tests logf with a normal set of values. -** -**===================================================================*/ - -#include - -// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (6-9 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON -// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use -// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10. -#define PAL_EPSILON 4.76837158e-07 - -#define PAL_NAN sqrtf(-1.0f) -#define PAL_POSINF -logf(0.0f) -#define PAL_NEGINF logf(0.0f) - -/** - * Helper test structure - */ -struct test -{ - float value; /* value to test the function with */ - float expected; /* expected result */ - float variance; /* maximum delta between the expected and actual result */ -}; - -/** - * logf_test1_validate - * - * test validation function - */ -void __cdecl logf_test1_validate(float value, float expected, float variance) -{ - float result = logf(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - float delta = fabsf(result - expected); - - if (delta > variance) - { - Fail("logf(%g) returned %10.9g when it should have returned %10.9g", - value, result, expected); - } -} - -/** - * logf_test1_validate - * - * test validation function for values returning NaN - */ -void __cdecl logf_test1_validate_isnan(float value) -{ - float result = logf(value); - - if (!_isnanf(result)) - { - Fail("logf(%g) returned %10.9g when it should have returned %10.9g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -PALTEST(c_runtime_logf_test1_paltest_logf_test1, "c_runtime/logf/test1/paltest_logf_test1") -{ - struct test tests[] = - { - /* value expected variance */ - { 0, PAL_NEGINF, 0 }, - { 0.0432139183f, -3.14159265f, PAL_EPSILON * 10 }, // expected: -(pi) - { 0.0659880358f, -2.71828183f, PAL_EPSILON * 10 }, // expected: -(e) - { 0.1f, -2.30258509f, PAL_EPSILON * 10 }, // expected: -(ln(10)) - { 0.207879576f, -1.57079633f, PAL_EPSILON * 10 }, // expected: -(pi / 2) - { 0.236290088f, -1.44269504f, PAL_EPSILON * 10 }, // expected: -(logf2(e)) - { 0.243116734f, -1.41421356f, PAL_EPSILON * 10 }, // expected: -(sqrtf(2)) - { 0.323557264f, -1.12837917f, PAL_EPSILON * 10 }, // expected: -(2 / sqrtf(pi)) - { 0.367879441f, -1, PAL_EPSILON * 10 }, // expected: -(1) - { 0.455938128f, -0.785398163f, PAL_EPSILON }, // expected: -(pi / 4) - { 0.493068691f, -0.707106781f, PAL_EPSILON }, // expected: -(1 / sqrtf(2)) - { 0.5f, -0.693147181f, PAL_EPSILON }, // expected: -(ln(2)) - { 0.529077808f, -0.636619772f, PAL_EPSILON }, // expected: -(2 / pi) - { 0.647721485f, -0.434294482f, PAL_EPSILON }, // expected: -(log10f(e)) - { 0.727377349f, -0.318309886f, PAL_EPSILON }, // expected: -(1 / pi) - { 1, 0, PAL_EPSILON }, - { 1.37480223f, 0.318309886f, PAL_EPSILON }, // expected: 1 / pi - { 1.54387344f, 0.434294482f, PAL_EPSILON }, // expected: log10f(e) - { 1.89008116f, 0.636619772f, PAL_EPSILON }, // expected: 2 / pi - { 2, 0.693147181f, PAL_EPSILON }, // expected: ln(2) - { 2.02811498f, 0.707106781f, PAL_EPSILON }, // expected: 1 / sqrtf(2) - { 2.19328005f, 0.785398163f, PAL_EPSILON }, // expected: pi / 4 - { 2.71828183f, 1, PAL_EPSILON * 10 }, // value: e - { 3.09064302f, 1.12837917f, PAL_EPSILON * 10 }, // expected: 2 / sqrtf(pi) - { 4.11325038f, 1.41421356f, PAL_EPSILON * 10 }, // expected: sqrtf(2) - { 4.23208611f, 1.44269504f, PAL_EPSILON * 10 }, // expected: logf2(e) - { 4.81047738f, 1.57079633f, PAL_EPSILON * 10 }, // expected: pi / 2 - { 10, 2.30258509f, PAL_EPSILON * 10 }, // expected: ln(10) - { 15.1542622f, 2.71828183f, PAL_EPSILON * 10 }, // expected: e - { 23.1406926f, 3.14159265f, PAL_EPSILON * 10 }, // expected: pi - { PAL_POSINF, PAL_POSINF, 0 }, - }; - - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - logf_test1_validate(tests[i].value, tests[i].expected, tests[i].variance); - } - - logf_test1_validate_isnan(PAL_NEGINF); - logf_test1_validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/modf/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/modf/test1/test1.cpp deleted file mode 100644 index 726e524d0a4e8e..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/modf/test1/test1.cpp +++ /dev/null @@ -1,135 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================= -** -** Source: test1.c (modf) -** -** Purpose: Test to ensure that modf return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabs -** -**===========================================================================*/ - -#include - -// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (15-17 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use -// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx -// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will -// use PAL_EPSILON * 10. -#define PAL_EPSILON 8.8817841970012523e-16 - -#define PAL_NAN sqrt(-1.0) -#define PAL_POSINF -log(0.0) -#define PAL_NEGINF log(0.0) - -/** - * Helper test structure - */ -struct test -{ - double value; /* value to test the function with */ - double expected; /* expected result */ - double variance; /* maximum delta between the expected and actual result */ - double expected_intpart; /* expected result */ - double variance_intpart; /* maximum delta between the expected and actual result */ -}; - -/** - * modf_test1_validate - * - * test validation function - */ -void __cdecl modf_test1_validate(double value, double expected, double variance, double expected_intpart, double variance_intpart) -{ - double result_intpart; - double result = modf(value, &result_intpart); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - double delta = fabs(result - expected); - double delta_intpart = fabs(result_intpart - expected_intpart); - - if ((delta > variance) || (delta_intpart > variance_intpart)) - { - Fail("modf(%g) returned %20.17g with an intpart of %20.17g when it should have returned %20.17g with an intpart of %20.17g", - value, result, result_intpart, expected, expected_intpart); - } -} - -/** - * modf_test1_validate - * - * test validation function for values returning NaN - */ -void __cdecl modf_test1_validate_isnan(double value) -{ - double result_intpart; - double result = modf(value, &result_intpart); - - if (!_isnan(result) || !_isnan(result_intpart)) - { - Fail("modf(%g) returned %20.17g with an intpart of %20.17g when it should have returned %20.17g with an intpart of %20.17g", - value, result, result_intpart, PAL_NAN, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -PALTEST(c_runtime_modf_test1_paltest_modf_test1, "c_runtime/modf/test1/paltest_modf_test1") -{ - struct test tests[] = - { - /* value expected variance expected_intpart variance_intpart */ - { 0, 0, PAL_EPSILON, 0, PAL_EPSILON }, - { 0.31830988618379067, 0.31830988618379067, PAL_EPSILON, 0, PAL_EPSILON }, // value: 1 / pi - { 0.43429448190325183, 0.43429448190325183, PAL_EPSILON, 0, PAL_EPSILON }, // value: log10(e) - { 0.63661977236758134, 0.63661977236758134, PAL_EPSILON, 0, PAL_EPSILON }, // value: 2 / pi - { 0.69314718055994531, 0.69314718055994531, PAL_EPSILON, 0, PAL_EPSILON }, // value: ln(2) - { 0.70710678118654752, 0.70710678118654752, PAL_EPSILON, 0, PAL_EPSILON }, // value: 1 / sqrt(2) - { 0.78539816339744831, 0.78539816339744831, PAL_EPSILON, 0, PAL_EPSILON }, // value: pi / 4 - { 1, 0, PAL_EPSILON, 1, PAL_EPSILON * 10 }, - { 1.1283791670955126, 0.1283791670955126, PAL_EPSILON, 1, PAL_EPSILON * 10 }, // value: 2 / sqrt(pi) - { 1.4142135623730950, 0.4142135623730950, PAL_EPSILON, 1, PAL_EPSILON * 10 }, // value: sqrt(2) - { 1.4426950408889634, 0.4426950408889634, PAL_EPSILON, 1, PAL_EPSILON * 10 }, // value: log2(e) - { 1.5707963267948966, 0.5707963267948966, PAL_EPSILON, 1, PAL_EPSILON * 10 }, // value: pi / 2 - { 2.3025850929940457, 0.3025850929940457, PAL_EPSILON, 2, PAL_EPSILON * 10 }, // value: ln(10) - { 2.7182818284590452, 0.7182818284590452, PAL_EPSILON, 2, PAL_EPSILON * 10 }, // value: e - { 3.1415926535897932, 0.1415926535897932, PAL_EPSILON, 3, PAL_EPSILON * 10 }, // value: pi - { PAL_POSINF, 0, PAL_EPSILON, PAL_POSINF, 0 } - - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - modf_test1_validate( tests[i].value, tests[i].expected, tests[i].variance, tests[i].expected_intpart, tests[i].variance_intpart); - modf_test1_validate(-tests[i].value, -tests[i].expected, tests[i].variance, -tests[i].expected_intpart, tests[i].variance_intpart); - } - - modf_test1_validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/modff/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/modff/test1/test1.cpp deleted file mode 100644 index 898566b27398b4..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/modff/test1/test1.cpp +++ /dev/null @@ -1,134 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================= -** -** Source: test1.c (modf) -** -** Purpose: Test to ensure that modf return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabs -** -**===========================================================================*/ - -#include - -// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (6-9 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON -// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use -// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10. -#define PAL_EPSILON 4.76837158e-07 - -#define PAL_NAN sqrt(-1.0) -#define PAL_POSINF -log(0.0) -#define PAL_NEGINF log(0.0) - -/** - * Helper test structure - */ -struct test -{ - float value; /* value to test the function with */ - float expected; /* expected result */ - float variance; /* maximum delta between the expected and actual result */ - float expected_intpart; /* expected result */ - float variance_intpart; /* maximum delta between the expected and actual result */ -}; - -/** - * modff_test1_validate - * - * test validation function - */ -void __cdecl modff_test1_validate(float value, float expected, float variance, float expected_intpart, float variance_intpart) -{ - float result_intpart; - float result = modff(value, &result_intpart); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - float delta = fabsf(result - expected); - float delta_intpart = fabsf(result_intpart - expected_intpart); - - if ((delta > variance) || (delta_intpart > variance_intpart)) - { - Fail("modff(%g) returned %10.9g with an intpart of %10.9g when it should have returned %10.9g with an intpart of %10.9g", - value, result, result_intpart, expected, expected_intpart); - } -} - -/** - * modff_test1_validate - * - * test validation function for values returning NaN - */ -void __cdecl modff_test1_validate_isnan(float value) -{ - float result_intpart; - float result = modff(value, &result_intpart); - - if (!_isnan(result) || !_isnan(result_intpart)) - { - Fail("modff(%g) returned %10.9g with an intpart of %10.9g when it should have returned %10.9g with an intpart of %10.9g", - value, result, result_intpart, PAL_NAN, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -PALTEST(c_runtime_modff_test1_paltest_modff_test1, "c_runtime/modff/test1/paltest_modff_test1") -{ - struct test tests[] = - { - /* value expected variance expected_intpart variance_intpart */ - { 0, 0, PAL_EPSILON, 0, PAL_EPSILON }, - { 0.318309886f, 0.318309886f, PAL_EPSILON, 0, PAL_EPSILON }, // value: 1 / pi - { 0.434294482f, 0.434294482f, PAL_EPSILON, 0, PAL_EPSILON }, // value: log10(e) - { 0.636619772f, 0.636619772f, PAL_EPSILON, 0, PAL_EPSILON }, // value: 2 / pi - { 0.693147181f, 0.693147181f, PAL_EPSILON, 0, PAL_EPSILON }, // value: ln(2) - { 0.707106781f, 0.707106781f, PAL_EPSILON, 0, PAL_EPSILON }, // value: 1 / sqrt(2) - { 0.785398163f, 0.785398163f, PAL_EPSILON, 0, PAL_EPSILON }, // value: pi / 4 - { 1, 0, PAL_EPSILON, 1, PAL_EPSILON * 10 }, - { 1.12837917f, 0.128379167f, PAL_EPSILON, 1, PAL_EPSILON * 10 }, // value: 2 / sqrt(pi) - { 1.41421356f, 0.414213562f, PAL_EPSILON, 1, PAL_EPSILON * 10 }, // value: sqrt(2) - { 1.44269504f, 0.442695041f, PAL_EPSILON, 1, PAL_EPSILON * 10 }, // value: log2(e) - { 1.57079633f, 0.570796327f, PAL_EPSILON, 1, PAL_EPSILON * 10 }, // value: pi / 2 - { 2.30258509f, 0.302585093f, PAL_EPSILON, 2, PAL_EPSILON * 10 }, // value: ln(10) - { 2.71828183f, 0.718281828f, PAL_EPSILON, 2, PAL_EPSILON * 10 }, // value: e - { 3.14159265f, 0.141592654f, PAL_EPSILON, 3, PAL_EPSILON * 10 }, // value: pi - { PAL_POSINF, 0, PAL_EPSILON, PAL_POSINF, 0 } - - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - modff_test1_validate( tests[i].value, tests[i].expected, tests[i].variance, tests[i].expected_intpart, tests[i].variance_intpart); - modff_test1_validate(-tests[i].value, -tests[i].expected, tests[i].variance, -tests[i].expected_intpart, tests[i].variance_intpart); - } - - modff_test1_validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/pow/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/pow/test1/test1.cpp deleted file mode 100644 index 22f482868b3d86..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/pow/test1/test1.cpp +++ /dev/null @@ -1,229 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Tests that atan2 returns correct values for a subset of values. -** Tests with positive and negative values of x and y to ensure -** atan2 is returning results from the correct quadrant. -** -**===================================================================*/ - -#include - -// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (15-17 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use -// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx -// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will -// use PAL_EPSILON * 10. -#define PAL_EPSILON 8.8817841970012523e-16 - -#define PAL_NAN sqrt(-1.0) -#define PAL_POSINF -log(0.0) -#define PAL_NEGINF log(0.0) - -/** - * Helper test structure - */ -struct test -{ - double x; /* first component of the value to test the function with */ - double y; /* second component of the value to test the function with */ - double expected; /* expected result */ - double variance; /* maximum delta between the expected and actual result */ -}; - -/** - * pow_test1_validate - * - * test validation function - */ -void __cdecl pow_test1_validate(double x, double y, double expected, double variance) -{ - double result = pow(x, y); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - double delta = fabs(result - expected); - - if (delta > variance) - { - Fail("pow(%g, %g) returned %20.17g when it should have returned %20.17g", - x, y, result, expected); - } -} - -/** - * pow_test1_validate - * - * test validation function for values returning NaN - */ -void __cdecl pow_test1_validate_isnan(double x, double y) -{ - double result = pow(x, y); - - if (!_isnan(result)) - { - Fail("pow(%g, %g) returned %20.17g when it should have returned %20.17g", - x, y, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -PALTEST(c_runtime_pow_test1_paltest_pow_test1, "c_runtime/pow/test1/paltest_pow_test1") -{ - struct test tests[] = - { - /* x y expected variance */ - { PAL_NEGINF, PAL_NEGINF, 0, PAL_EPSILON }, - { PAL_NEGINF, PAL_POSINF, PAL_POSINF, 0 }, - - { -10, PAL_NEGINF, 0, PAL_EPSILON }, - { -10, -1, -0.1, PAL_EPSILON }, - { -10, 0, 1, PAL_EPSILON * 10 }, - { -10, 1, -10, PAL_EPSILON * 100 }, - { -10, PAL_POSINF, PAL_POSINF, 0 }, - - { -2.7182818284590452, PAL_NEGINF, 0, PAL_EPSILON }, // x: -(e) - { -2.7182818284590452, -1, -0.36787944117144232, PAL_EPSILON }, // x: -(e) - { -2.7182818284590452, 0, 1, PAL_EPSILON * 10 }, // x: -(e) - { -2.7182818284590452, 1, -2.7182818284590452, PAL_EPSILON * 10 }, // x: -(e) expected: e - { -2.7182818284590452, PAL_POSINF, PAL_POSINF, 0 }, // x: -(e) - - { -1.0, PAL_NEGINF, 1.0, PAL_EPSILON * 10 }, - { -1.0, PAL_POSINF, 1.0, PAL_EPSILON * 10 }, - - { -0.0, PAL_NEGINF, PAL_POSINF, 0 }, - { -0.0, -1, PAL_NEGINF, 0 }, - { -0.0, -0.0, 1, PAL_EPSILON * 10 }, - { -0.0, 0, 1, PAL_EPSILON * 10 }, - { -0.0, 1, -0.0, PAL_EPSILON }, - { -0.0, PAL_POSINF, 0, PAL_EPSILON }, - - { PAL_NAN, -0.0, 1.0, PAL_EPSILON * 10 }, - { PAL_NAN, 0, 1.0, PAL_EPSILON * 10 }, - - { 0.0, PAL_NEGINF, PAL_POSINF, 0 }, - { 0.0, -1, PAL_POSINF, 0 }, - { 0, -0.0, 1, PAL_EPSILON * 10 }, - { 0, 0, 1, PAL_EPSILON * 10 }, - { 0.0, 1, 0, PAL_EPSILON }, - { 0.0, PAL_POSINF, 0, PAL_EPSILON }, - - { 1, PAL_NEGINF, 1, PAL_EPSILON * 10 }, - { 1, PAL_POSINF, 1, PAL_EPSILON * 10 }, - - { 2.7182818284590452, PAL_NEGINF, 0, PAL_EPSILON }, - { 2.7182818284590452, -3.1415926535897932, 0.043213918263772250, PAL_EPSILON / 10 }, // x: e y: -(pi) - { 2.7182818284590452, -2.7182818284590452, 0.065988035845312537, PAL_EPSILON / 10 }, // x: e y: -(e) - { 2.7182818284590452, -2.3025850929940457, 0.1, PAL_EPSILON }, // x: e y: -(ln(10)) - { 2.7182818284590452, -1.5707963267948966, 0.20787957635076191, PAL_EPSILON }, // x: e y: -(pi / 2) - { 2.7182818284590452, -1.4426950408889634, 0.23629008834452270, PAL_EPSILON }, // x: e y: -(log2(e)) - { 2.7182818284590452, -1.4142135623730950, 0.24311673443421421, PAL_EPSILON }, // x: e y: -(sqrt(2)) - { 2.7182818284590452, -1.1283791670955126, 0.32355726390307110, PAL_EPSILON }, // x: e y: -(2 / sqrt(pi)) - { 2.7182818284590452, -1, 0.36787944117144232, PAL_EPSILON }, // x: e y: -(1) - { 2.7182818284590452, -0.78539816339744831, 0.45593812776599624, PAL_EPSILON }, // x: e y: -(pi / 4) - { 2.7182818284590452, -0.70710678118654752, 0.49306869139523979, PAL_EPSILON }, // x: e y: -(1 / sqrt(2)) - { 2.7182818284590452, -0.69314718055994531, 0.5, PAL_EPSILON }, // x: e y: -(ln(2)) - { 2.7182818284590452, -0.63661977236758134, 0.52907780826773535, PAL_EPSILON }, // x: e y: -(2 / pi) - { 2.7182818284590452, -0.43429448190325183, 0.64772148514180065, PAL_EPSILON }, // x: e y: -(log10(e)) - { 2.7182818284590452, -0.31830988618379067, 0.72737734929521647, PAL_EPSILON }, // x: e y: -(1 / pi) - { 2.7182818284590452, 0, 1, PAL_EPSILON * 10 }, // x: e - { 2.7182818284590452, 0.31830988618379067, 1.3748022274393586, PAL_EPSILON * 10 }, // x: e y: 1 / pi - { 2.7182818284590452, 0.43429448190325183, 1.5438734439711811, PAL_EPSILON * 10 }, // x: e y: log10(e) - { 2.7182818284590452, 0.63661977236758134, 1.8900811645722220, PAL_EPSILON * 10 }, // x: e y: 2 / pi - { 2.7182818284590452, 0.69314718055994531, 2, PAL_EPSILON * 10 }, // x: e y: ln(2) - { 2.7182818284590452, 0.70710678118654752, 2.0281149816474725, PAL_EPSILON * 10 }, // x: e y: 1 / sqrt(2) - { 2.7182818284590452, 0.78539816339744831, 2.1932800507380155, PAL_EPSILON * 10 }, // x: e y: pi / 4 - { 2.7182818284590452, 1, 2.7182818284590452, PAL_EPSILON * 10 }, // x: e expected: e - { 2.7182818284590452, 1.1283791670955126, 3.0906430223107976, PAL_EPSILON * 10 }, // x: e y: 2 / sqrt(pi) - { 2.7182818284590452, 1.4142135623730950, 4.1132503787829275, PAL_EPSILON * 10 }, // x: e y: sqrt(2) - { 2.7182818284590452, 1.4426950408889634, 4.2320861065570819, PAL_EPSILON * 10 }, // x: e y: log2(e) - { 2.7182818284590452, 1.5707963267948966, 4.8104773809653517, PAL_EPSILON * 10 }, // x: e y: pi / 2 - { 2.7182818284590452, 2.3025850929940457, 10, PAL_EPSILON * 100 }, // x: e y: ln(10) - { 2.7182818284590452, 2.7182818284590452, 15.154262241479264, PAL_EPSILON * 100 }, // x: e y: e - { 2.7182818284590452, 3.1415926535897932, 23.140692632779269, PAL_EPSILON * 100 }, // x: e y: pi - { 2.7182818284590452, PAL_POSINF, PAL_POSINF, 0 }, // x: e - - { 10, PAL_NEGINF, 0, 0 }, - { 10, -3.1415926535897932, 0.00072178415907472774, PAL_EPSILON / 1000 }, // y: -(pi) - { 10, -2.7182818284590452, 0.0019130141022243176, PAL_EPSILON / 100 }, // y: -(e) - { 10, -2.3025850929940457, 0.0049821282964407206, PAL_EPSILON / 100 }, // y: -(ln(10)) - { 10, -1.5707963267948966, 0.026866041001136132, PAL_EPSILON / 10 }, // y: -(pi / 2) - { 10, -1.4426950408889634, 0.036083192820787210, PAL_EPSILON / 10 }, // y: -(log2(e)) - { 10, -1.4142135623730950, 0.038528884700322026, PAL_EPSILON / 10 }, // y: -(sqrt(2)) - { 10, -1.1283791670955126, 0.074408205860642723, PAL_EPSILON / 10 }, // y: -(2 / sqrt(pi)) - { 10, -1, 0.1, PAL_EPSILON }, // y: -(1) - { 10, -0.78539816339744831, 0.16390863613957665, PAL_EPSILON }, // y: -(pi / 4) - { 10, -0.70710678118654752, 0.19628775993505562, PAL_EPSILON }, // y: -(1 / sqrt(2)) - { 10, -0.69314718055994531, 0.20269956628651730, PAL_EPSILON }, // y: -(ln(2)) - { 10, -0.63661977236758134, 0.23087676451600055, PAL_EPSILON }, // y: -(2 / pi) - { 10, -0.43429448190325183, 0.36787944117144232, PAL_EPSILON }, // y: -(log10(e)) - { 10, -0.31830988618379067, 0.48049637305186868, PAL_EPSILON }, // y: -(1 / pi) - { 10, 0, 1, PAL_EPSILON * 10 }, - { 10, 0.31830988618379067, 2.0811811619898573, PAL_EPSILON * 10 }, // y: 1 / pi - { 10, 0.43429448190325183, 2.7182818284590452, PAL_EPSILON * 10 }, // y: log10(e) expected: e - { 10, 0.63661977236758134, 4.3313150290214525, PAL_EPSILON * 10 }, // y: 2 / pi - { 10, 0.69314718055994531, 4.9334096679145963, PAL_EPSILON * 10 }, // y: ln(2) - { 10, 0.70710678118654752, 5.0945611704512962, PAL_EPSILON * 10 }, // y: 1 / sqrt(2) - { 10, 0.78539816339744831, 6.1009598002416937, PAL_EPSILON * 10 }, // y: pi / 4 - { 10, 1, 10, PAL_EPSILON * 100 }, - { 10, 1.1283791670955126, 13.439377934644400, PAL_EPSILON * 100 }, // y: 2 / sqrt(pi) - { 10, 1.4142135623730950, 25.954553519470081, PAL_EPSILON * 100 }, // y: sqrt(2) - { 10, 1.4426950408889634, 27.713733786437790, PAL_EPSILON * 100 }, // y: log2(e) - { 10, 1.5707963267948966, 37.221710484165167, PAL_EPSILON * 100 }, // y: pi / 2 - { 10, 2.3025850929940457, 200.71743249053009, PAL_EPSILON * 1000 }, // y: ln(10) - { 10, 2.7182818284590452, 522.73529967043665, PAL_EPSILON * 1000 }, // y: e - { 10, 3.1415926535897932, 1385.4557313670111, PAL_EPSILON * 10000 }, // y: pi - { 10, PAL_POSINF, PAL_POSINF, 0 }, - - { PAL_POSINF, PAL_NEGINF, 0, PAL_EPSILON }, - { PAL_POSINF, PAL_POSINF, PAL_POSINF, 0 }, - }; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - pow_test1_validate(tests[i].x, tests[i].y, tests[i].expected, tests[i].variance); - } - - pow_test1_validate_isnan(-10, -1.5707963267948966); // y: -(pi / 2) - pow_test1_validate_isnan(-10, -0.78539816339744828); // y: -(pi / 4) - pow_test1_validate_isnan(-10, 0.78539816339744828); // y: pi / 4 - pow_test1_validate_isnan(-10, 1.5707963267948966); // y: pi / 2 - - pow_test1_validate_isnan(-2.7182818284590452, -1.5707963267948966); // x: -(e) y: -(pi / 2) - pow_test1_validate_isnan(-2.7182818284590452, -0.78539816339744828); // x: -(e) y: -(pi / 4) - pow_test1_validate_isnan(-2.7182818284590452, 0.78539816339744828); // x: -(e) y: pi / 4 - pow_test1_validate_isnan(-2.7182818284590452, 1.5707963267948966); // x: -(e) y: pi / 2 - - pow_test1_validate_isnan(PAL_NEGINF, PAL_NAN); - pow_test1_validate_isnan(PAL_NAN, PAL_NEGINF); - - pow_test1_validate_isnan(PAL_POSINF, PAL_NAN); - pow_test1_validate_isnan(PAL_NAN, PAL_POSINF); - - pow_test1_validate_isnan(PAL_NAN, PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/powf/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/powf/test1/test1.cpp deleted file mode 100644 index 5e704f2d59b612..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/powf/test1/test1.cpp +++ /dev/null @@ -1,228 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Tests that atan2f returns correct values for a subset of values. -** Tests with positive and negative values of x and y to ensure -** atan2f is returning results from the correct quadrant. -** -**===================================================================*/ - -#include - -// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (6-9 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON -// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use -// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10. -#define PAL_EPSILON 4.76837158e-07 - -#define PAL_NAN sqrtf(-1.0f) -#define PAL_POSINF -logf(0.0f) -#define PAL_NEGINF logf(0.0f) - -/** - * Helper test structure - */ -struct test -{ - float x; /* first component of the value to test the function with */ - float y; /* second component of the value to test the function with */ - float expected; /* expected result */ - float variance; /* maximum delta between the expected and actual result */ -}; - -/** - * powf_test1_validate - * - * test validation function - */ -void __cdecl powf_test1_validate(float x, float y, float expected, float variance) -{ - float result = powf(x, y); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - float delta = fabsf(result - expected); - - if (delta > variance) - { - Fail("powf(%g, %g) returned %10.9g when it should have returned %10.9g", - x, y, result, expected); - } -} - -/** - * powf_test1_validate - * - * test validation function for values returning NaN - */ -void __cdecl powf_test1_validate_isnan(float x, float y) -{ - float result = powf(x, y); - - if (!_isnanf(result)) - { - Fail("powf(%g, %g) returned %10.9g when it should have returned %10.9g", - x, y, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -PALTEST(c_runtime_powf_test1_paltest_powf_test1, "c_runtime/powf/test1/paltest_powf_test1") -{ - struct test tests[] = - { - /* x y expected variance */ - { PAL_NEGINF, PAL_NEGINF, 0, PAL_EPSILON }, - { PAL_NEGINF, PAL_POSINF, PAL_POSINF, 0 }, - - { -10, PAL_NEGINF, 0, PAL_EPSILON }, - { -10, -1, -0.1f, PAL_EPSILON }, - { -10, 0, 1, PAL_EPSILON * 10 }, - { -10, 1, -10, PAL_EPSILON * 100 }, - { -10, PAL_POSINF, PAL_POSINF, 0 }, - - { -2.71828183f, PAL_NEGINF, 0, PAL_EPSILON }, // x: -(e) - { -2.71828183f, -1, -0.367879441f, PAL_EPSILON }, // x: -(e) - { -2.71828183f, 0, 1, PAL_EPSILON * 10 }, // x: -(e) - { -2.71828183f, 1, -2.71828183f, PAL_EPSILON * 10 }, // x: -(e) expected: e - { -2.71828183f, PAL_POSINF, PAL_POSINF, 0 }, // x: -(e) - - { -1.0, PAL_NEGINF, 1.0, PAL_EPSILON * 10 }, - { -1.0, PAL_POSINF, 1.0, PAL_EPSILON * 10 }, - - { -0.0, PAL_NEGINF, PAL_POSINF, 0 }, - { -0.0, -1, PAL_NEGINF, 0 }, - { -0.0f, -0.0f, 1, PAL_EPSILON * 10 }, - { -0.0f, 0, 1, PAL_EPSILON * 10 }, - { -0.0, 1, -0.0, PAL_EPSILON }, - { -0.0, PAL_POSINF, 0, PAL_EPSILON }, - - { PAL_NAN, -0.0, 1.0, PAL_EPSILON * 10 }, - { PAL_NAN, 0, 1.0, PAL_EPSILON * 10 }, - - { 0.0, PAL_NEGINF, PAL_POSINF, 0 }, - { 0.0, -1, PAL_POSINF, 0 }, - { 0, -0.0f, 1, PAL_EPSILON * 10 }, - { 0, 0, 1, PAL_EPSILON * 10 }, - { 0.0, 1, 0, PAL_EPSILON }, - { 0.0, PAL_POSINF, 0, PAL_EPSILON }, - - { 1, PAL_NEGINF, 1, PAL_EPSILON * 10 }, - { 1, PAL_POSINF, 1, PAL_EPSILON * 10 }, - - { 2.71828183f, PAL_NEGINF, 0, PAL_EPSILON }, - { 2.71828183f, -3.14159265f, 0.0432139183f, PAL_EPSILON / 10 }, // x: e y: -(pi) - { 2.71828183f, -2.71828183f, 0.0659880358f, PAL_EPSILON / 10 }, // x: e y: -(e) - { 2.71828183f, -2.30258509f, 0.1f, PAL_EPSILON }, // x: e y: -(ln(10)) - { 2.71828183f, -1.57079633f, 0.207879576f, PAL_EPSILON }, // x: e y: -(pi / 2) - { 2.71828183f, -1.44269504f, 0.236290088f, PAL_EPSILON }, // x: e y: -(logf2(e)) - { 2.71828183f, -1.41421356f, 0.243116734f, PAL_EPSILON }, // x: e y: -(sqrtf(2)) - { 2.71828183f, -1.12837917f, 0.323557264f, PAL_EPSILON }, // x: e y: -(2 / sqrtf(pi)) - { 2.71828183f, -1, 0.367879441f, PAL_EPSILON }, // x: e y: -(1) - { 2.71828183f, -0.785398163f, 0.455938128f, PAL_EPSILON }, // x: e y: -(pi / 4) - { 2.71828183f, -0.707106781f, 0.493068691f, PAL_EPSILON }, // x: e y: -(1 / sqrtf(2)) - { 2.71828183f, -0.693147181f, 0.5f, PAL_EPSILON }, // x: e y: -(ln(2)) - { 2.71828183f, -0.636619772f, 0.529077808f, PAL_EPSILON }, // x: e y: -(2 / pi) - { 2.71828183f, -0.434294482f, 0.647721485f, PAL_EPSILON }, // x: e y: -(log10f(e)) - { 2.71828183f, -0.318309886f, 0.727377349f, PAL_EPSILON }, // x: e y: -(1 / pi) - { 2.71828183f, 0, 1, PAL_EPSILON * 10 }, // x: e - { 2.71828183f, 0.318309886f, 1.37480223f, PAL_EPSILON * 10 }, // x: e y: 1 / pi - { 2.71828183f, 0.434294482f, 1.54387344f, PAL_EPSILON * 10 }, // x: e y: log10f(e) - { 2.71828183f, 0.636619772f, 1.89008116f, PAL_EPSILON * 10 }, // x: e y: 2 / pi - { 2.71828183f, 0.693147181f, 2, PAL_EPSILON * 10 }, // x: e y: ln(2) - { 2.71828183f, 0.707106781f, 2.02811498f, PAL_EPSILON * 10 }, // x: e y: 1 / sqrtf(2) - { 2.71828183f, 0.785398163f, 2.19328005f, PAL_EPSILON * 10 }, // x: e y: pi / 4 - { 2.71828183f, 1, 2.71828183f, PAL_EPSILON * 10 }, // x: e expected: e - { 2.71828183f, 1.12837917f, 3.09064302f, PAL_EPSILON * 10 }, // x: e y: 2 / sqrtf(pi) - { 2.71828183f, 1.41421356f, 4.11325038f, PAL_EPSILON * 10 }, // x: e y: sqrtf(2) - { 2.71828183f, 1.44269504f, 4.23208611f, PAL_EPSILON * 10 }, // x: e y: logf2(e) - { 2.71828183f, 1.57079633f, 4.81047738f, PAL_EPSILON * 10 }, // x: e y: pi / 2 - { 2.71828183f, 2.30258509f, 10, PAL_EPSILON * 100 }, // x: e y: ln(10) - { 2.71828183f, 2.71828183f, 15.1542622f, PAL_EPSILON * 100 }, // x: e y: e - { 2.71828183f, 3.14159265f, 23.1406926f, PAL_EPSILON * 100 }, // x: e y: pi - { 2.71828183f, PAL_POSINF, PAL_POSINF, 0 }, // x: e - - { 10, PAL_NEGINF, 0, 0 }, - { 10, -3.14159265f, 0.000721784159f, PAL_EPSILON / 1000 }, // y: -(pi) - { 10, -2.71828183f, 0.00191301410f, PAL_EPSILON / 100 }, // y: -(e) - { 10, -2.30258509f, 0.00498212830f, PAL_EPSILON / 100 }, // y: -(ln(10)) - { 10, -1.57079633f, 0.0268660410f, PAL_EPSILON / 10 }, // y: -(pi / 2) - { 10, -1.44269504f, 0.0360831928f, PAL_EPSILON / 10 }, // y: -(logf2(e)) - { 10, -1.41421356f, 0.0385288847f, PAL_EPSILON / 10 }, // y: -(sqrtf(2)) - { 10, -1.12837917f, 0.0744082059f, PAL_EPSILON / 10 }, // y: -(2 / sqrtf(pi)) - { 10, -1, 0.1f, PAL_EPSILON }, // y: -(1) - { 10, -0.785398163f, 0.163908636f, PAL_EPSILON }, // y: -(pi / 4) - { 10, -0.707106781f, 0.196287760f, PAL_EPSILON }, // y: -(1 / sqrtf(2)) - { 10, -0.693147181f, 0.202699566f, PAL_EPSILON }, // y: -(ln(2)) - { 10, -0.636619772f, 0.230876765f, PAL_EPSILON }, // y: -(2 / pi) - { 10, -0.434294482f, 0.367879441f, PAL_EPSILON }, // y: -(log10f(e)) - { 10, -0.318309886f, 0.480496373f, PAL_EPSILON }, // y: -(1 / pi) - { 10, 0, 1, PAL_EPSILON * 10 }, - { 10, 0.318309886f, 2.08118116f, PAL_EPSILON * 10 }, // y: 1 / pi - { 10, 0.434294482f, 2.71828183f, PAL_EPSILON * 10 }, // y: log10f(e) expected: e - { 10, 0.636619772f, 4.33131503f, PAL_EPSILON * 10 }, // y: 2 / pi - { 10, 0.693147181f, 4.93340967f, PAL_EPSILON * 10 }, // y: ln(2) - { 10, 0.707106781f, 5.09456117f, PAL_EPSILON * 10 }, // y: 1 / sqrtf(2) - { 10, 0.785398163f, 6.10095980f, PAL_EPSILON * 10 }, // y: pi / 4 - { 10, 1, 10, PAL_EPSILON * 100 }, - { 10, 1.12837917f, 13.4393779f, PAL_EPSILON * 100 }, // y: 2 / sqrtf(pi) - { 10, 1.41421356f, 25.9545535f, PAL_EPSILON * 100 }, // y: sqrtf(2) - { 10, 1.44269504f, 27.7137338f, PAL_EPSILON * 100 }, // y: logf2(e) - { 10, 1.57079633f, 37.2217105f, PAL_EPSILON * 100 }, // y: pi / 2 - { 10, 2.30258509f, 200.717432f, PAL_EPSILON * 1000 }, // y: ln(10) - { 10, 2.71828183f, 522.735300f, PAL_EPSILON * 1000 }, // y: e - { 10, 3.14159265f, 1385.45573f, PAL_EPSILON * 10000 }, // y: pi - { 10, PAL_POSINF, PAL_POSINF, 0 }, - - { PAL_POSINF, PAL_NEGINF, 0, PAL_EPSILON }, - { PAL_POSINF, PAL_POSINF, PAL_POSINF, 0 }, - }; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - powf_test1_validate(tests[i].x, tests[i].y, tests[i].expected, tests[i].variance); - } - - powf_test1_validate_isnan(-10, -1.57079633f); // y: -(pi / 2) - powf_test1_validate_isnan(-10, -0.785398163f); // y: -(pi / 4) - powf_test1_validate_isnan(-10, 0.785398163f); // y: pi / 4 - powf_test1_validate_isnan(-10, 1.57079633f); // y: pi / 2 - - powf_test1_validate_isnan(-2.71828183f, -1.57079633f); // x: -(e) y: -(pi / 2) - powf_test1_validate_isnan(-2.71828183f, -0.785398163f); // x: -(e) y: -(pi / 4) - powf_test1_validate_isnan(-2.71828183f, 0.785398163f); // x: -(e) y: pi / 4 - powf_test1_validate_isnan(-2.71828183f, 1.57079633f); // x: -(e) y: pi / 2 - - powf_test1_validate_isnan(PAL_NEGINF, PAL_NAN); - powf_test1_validate_isnan(PAL_NAN, PAL_NEGINF); - - powf_test1_validate_isnan(PAL_POSINF, PAL_NAN); - powf_test1_validate_isnan(PAL_NAN, PAL_POSINF); - - powf_test1_validate_isnan(PAL_NAN, PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/sin/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/sin/test1/test1.cpp deleted file mode 100644 index bcfeb4baa05158..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/sin/test1/test1.cpp +++ /dev/null @@ -1,130 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that sin return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabs -** -**===========================================================================*/ - -#include - -// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (15-17 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use -// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx -// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will -// use PAL_EPSILON * 10. -#define PAL_EPSILON 8.8817841970012523e-16 - -#define PAL_NAN sqrt(-1.0) -#define PAL_POSINF -log(0.0) -#define PAL_NEGINF log(0.0) - -/** - * Helper test structure - */ -struct test -{ - double value; /* value to test the function with */ - double expected; /* expected result */ - double variance; /* maximum delta between the expected and actual result */ -}; - -/** - * sin_test1_validate - * - * test validation function - */ -void __cdecl sin_test1_validate(double value, double expected, double variance) -{ - double result = sin(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - double delta = fabs(result - expected); - - if (delta > variance) - { - Fail("sin(%g) returned %20.17g when it should have returned %20.17g", - value, result, expected); - } -} - -/** - * sin_test1_validate - * - * test validation function for values returning NaN - */ -void __cdecl sin_test1_validate_isnan(double value) -{ - double result = sin(value); - - if (!_isnan(result)) - { - Fail("sin(%g) returned %20.17g when it should have returned %20.17g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -PALTEST(c_runtime_sin_test1_paltest_sin_test1, "c_runtime/sin/test1/paltest_sin_test1") -{ - struct test tests[] = - { - /* value expected variance */ - { 0, 0, PAL_EPSILON }, - { 0.31830988618379067, 0.31296179620778659, PAL_EPSILON }, // value: 1 / pi - { 0.43429448190325183, 0.42077048331375735, PAL_EPSILON }, // value: log10(e) - { 0.63661977236758134, 0.59448076852482208, PAL_EPSILON }, // value: 2 / pi - { 0.69314718055994531, 0.63896127631363480, PAL_EPSILON }, // value: ln(2) - { 0.70710678118654752, 0.64963693908006244, PAL_EPSILON }, // value: 1 / sqrt(2) - { 0.78539816339744831, 0.70710678118654752, PAL_EPSILON }, // value: pi / 4, expected: 1 / sqrt(2) - { 1, 0.84147098480789651, PAL_EPSILON }, - { 1.1283791670955126, 0.90371945743584630, PAL_EPSILON }, // value: 2 / sqrt(pi) - { 1.4142135623730950, 0.98776594599273553, PAL_EPSILON }, // value: sqrt(2) - { 1.4426950408889634, 0.99180624439366372, PAL_EPSILON }, // value: log2(e) - { 1.5707963267948966, 1, PAL_EPSILON * 10 }, // value: pi / 2 - { 2.3025850929940457, 0.74398033695749319, PAL_EPSILON }, // value: ln(10) - { 2.7182818284590452, 0.41078129050290870, PAL_EPSILON }, // value: e - { 3.1415926535897932, 0, PAL_EPSILON }, // value: pi - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - sin_test1_validate( tests[i].value, tests[i].expected, tests[i].variance); - sin_test1_validate(-tests[i].value, -tests[i].expected, tests[i].variance); - } - - sin_test1_validate_isnan(PAL_NEGINF); - sin_test1_validate_isnan(PAL_NAN); - sin_test1_validate_isnan(PAL_POSINF); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/sincos/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/sincos/test1/test1.cpp deleted file mode 100644 index e2734652a3e7b5..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/sincos/test1/test1.cpp +++ /dev/null @@ -1,135 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that sincos return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabs -** -**===========================================================================*/ - -#include - -// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (15-17 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use -// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx -// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will -// use PAL_EPSILON * 10. -#define PAL_EPSILON 8.8817841970012523e-16 - -#define PAL_NAN sqrt(-1.0) -#define PAL_POSINF -log(0.0) -#define PAL_NEGINF log(0.0) - -/** - * Helper test structure - */ -struct test -{ - double value; /* value to test the function with */ - double expected_sin; /* expected sin result */ - double expected_cos; /* expected cos result */ - double variance_sin; /* maximum delta between the expected and actual sin result */ - double variance_cos; /* maximum delta between the expected and actual cos result */ -}; - -/** - * sincos_test1_validate - * - * test validation function - */ -void __cdecl sincos_test1_validate(double value, double expected_sin, double expected_cos, double variance_sin, double variance_cos) -{ - double result_sin, result_cos; - sincos(value, &result_sin, &result_cos); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - double delta_sin = fabs(result_sin - expected_sin); - double delta_cos = fabs(result_cos - expected_cos); - - if ((delta_sin > variance_sin) || (delta_cos > variance_cos)) - { - Fail("sincos(%g) returned (%20.17g, %20.17g) when it should have returned (%20.17g, %20.17g)", - value, result_sin, result_cos, expected_sin, expected_cos); - } -} - -/** - * sincos_test1_validate - * - * test validation function for values returning NaN - */ -void __cdecl sincos_test1_validate_isnan(double value) -{ - double result_sin, result_cos; - sincos(value, &result_sin, &result_cos); - - if (!_isnan(result_sin) || !_isnan(result_cos)) - { - Fail("sincos(%g) returned (%20.17g, %20.17g) when it should have returned (%20.17g, %20.17g)", - value, result_sin, result_cos, PAL_NAN, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -PALTEST(c_runtime_sincos_test1_paltest_sincos_test1, "c_runtime/sincos/test1/paltest_sincos_test1") -{ - struct test tests[] = - { - /* value expected_sin expected_cos variance_sin variance_cos */ - { 0, 0, 1, PAL_EPSILON, PAL_EPSILON * 10 }, - { 0.31830988618379067, 0.31296179620778659, 0.94976571538163866, PAL_EPSILON, PAL_EPSILON }, // value: 1 / pi - { 0.43429448190325183, 0.42077048331375735, 0.90716712923909839, PAL_EPSILON, PAL_EPSILON }, // value: log10(e) - { 0.63661977236758134, 0.59448076852482208, 0.80410982822879171, PAL_EPSILON, PAL_EPSILON }, // value: 2 / pi - { 0.69314718055994531, 0.63896127631363480, 0.76923890136397213, PAL_EPSILON, PAL_EPSILON }, // value: ln(2) - { 0.70710678118654752, 0.64963693908006244, 0.76024459707563015, PAL_EPSILON, PAL_EPSILON }, // value: 1 / sqrt(2) - { 0.78539816339744831, 0.70710678118654752, 0.70710678118654752, PAL_EPSILON, PAL_EPSILON }, // value: pi / 4, expected_sin: 1 / sqrtf(2), expected_cos: 1 - { 1, 0.84147098480789651, 0.54030230586813972, PAL_EPSILON, PAL_EPSILON }, - { 1.1283791670955126, 0.90371945743584630, 0.42812514788535792, PAL_EPSILON, PAL_EPSILON }, // value: 2 / sqrt(pi) - { 1.4142135623730950, 0.98776594599273553, 0.15594369476537447, PAL_EPSILON, PAL_EPSILON }, // value: sqrt(2) - { 1.4426950408889634, 0.99180624439366372, 0.12775121753523991, PAL_EPSILON, PAL_EPSILON }, // value: log2(e) - { 1.5707963267948966, 1, 0, PAL_EPSILON * 10, PAL_EPSILON }, // value: pi / 2 - { 2.3025850929940457, 0.74398033695749319, -0.66820151019031295, PAL_EPSILON, PAL_EPSILON }, // value: ln(10) - { 2.7182818284590452, 0.41078129050290870, -0.91173391478696510, PAL_EPSILON, PAL_EPSILON }, // value: e - { 3.1415926535897932, 0, -1, PAL_EPSILON, PAL_EPSILON * 10 }, // value: pi - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - sincos_test1_validate( tests[i].value, tests[i].expected_sin, tests[i].expected_cos, tests[i].variance_sin, tests[i].variance_cos); - sincos_test1_validate(-tests[i].value, -tests[i].expected_sin, tests[i].expected_cos, tests[i].variance_sin, tests[i].variance_cos); - } - - sincos_test1_validate_isnan(PAL_NEGINF); - sincos_test1_validate_isnan(PAL_NAN); - sincos_test1_validate_isnan(PAL_POSINF); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/sincosf/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/sincosf/test1/test1.cpp deleted file mode 100644 index 7332309e3d48ba..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/sincosf/test1/test1.cpp +++ /dev/null @@ -1,134 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that sincosf return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabs -** -**===========================================================================*/ - -#include - -// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (6-9 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON -// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use -// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10. -#define PAL_EPSILON 4.76837158e-07 - -#define PAL_NAN sqrtf(-1.0f) -#define PAL_POSINF -logf(0.0f) -#define PAL_NEGINF logf(0.0f) - -/** - * Helper test structure - */ -struct test -{ - float value; /* value to test the function with */ - float expected_sin; /* expected sin result */ - float expected_cos; /* expected cos result */ - float variance_sin; /* maximum delta between the expected and actual sin result */ - float variance_cos; /* maximum delta between the expected and actual cos result */ -}; - -/** - * sincosf_test1_validate - * - * test validation function - */ -void __cdecl sincosf_test1_validate(float value, float expected_sin, float expected_cos, float variance_sin, float variance_cos) -{ - float result_sin, result_cos; - sincosf(value, &result_sin, &result_cos); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - float delta_sin = fabsf(result_sin - expected_sin); - float delta_cos = fabsf(result_cos - expected_cos); - - if ((delta_sin > variance_sin) || (delta_cos > variance_cos)) - { - Fail("sincosf(%g) returned (%10.9g, %10.9g) when it should have returned (%10.9g, %10.9g)", - value, result_sin, result_cos, expected_sin, expected_cos); - } -} - -/** - * sincosf_test1_validate - * - * test validation function for values returning NaN - */ -void __cdecl sincosf_test1_validate_isnan(float value) -{ - float result_sin, result_cos; - sincosf(value, &result_sin, &result_cos); - - if (!_isnanf(result_sin) || !_isnanf(result_cos)) - { - Fail("sincosf(%g) returned (%10.9g, %10.9g) when it should have returned (%10.9g, %10.9g)", - value, result_sin, result_cos, PAL_NAN, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -PALTEST(c_runtime_sincosf_test1_paltest_sincosf_test1, "c_runtime/sincosf/test1/paltest_sincosf_test1") -{ - struct test tests[] = - { - /* value expected_sin expected_cos variance_sin variance_cos */ - { 0, 0, 1, PAL_EPSILON, PAL_EPSILON * 10 }, - { 0.318309886f, 0.312961796f, 0.949765715f, PAL_EPSILON, PAL_EPSILON }, // value: 1 / pi - { 0.434294482f, 0.420770483f, 0.907167129f, PAL_EPSILON, PAL_EPSILON }, // value: log10f(e) - { 0.636619772f, 0.594480769f, 0.804109828f, PAL_EPSILON, PAL_EPSILON }, // value: 2 / pi - { 0.693147181f, 0.638961276f, 0.769238901f, PAL_EPSILON, PAL_EPSILON }, // value: ln(2) - { 0.707106781f, 0.649636939f, 0.760244597f, PAL_EPSILON, PAL_EPSILON }, // value: 1 / sqrtf(2) - { 0.785398163f, 0.707106781f, 0.707106781f, PAL_EPSILON, PAL_EPSILON }, // value: pi / 4, expected_sin: 1 / sqrtf(2), expected_cos: 1 - { 1, 0.841470985f, 0.540302306f, PAL_EPSILON, PAL_EPSILON }, - { 1.12837917f, 0.903719457f, 0.428125148f, PAL_EPSILON, PAL_EPSILON }, // value: 2 / sqrtf(pi) - { 1.41421356f, 0.987765946f, 0.155943695f, PAL_EPSILON, PAL_EPSILON }, // value: sqrtf(2) - { 1.44269504f, 0.991806244f, 0.127751218f, PAL_EPSILON, PAL_EPSILON }, // value: logf2(e) - { 1.57079633f, 1, 0, PAL_EPSILON * 10, PAL_EPSILON }, // value: pi / 2 - { 2.30258509f, 0.743980337f, -0.668201510f, PAL_EPSILON, PAL_EPSILON }, // value: ln(10) - { 2.71828183f, 0.410781291f, -0.911733918f, PAL_EPSILON, PAL_EPSILON }, // value: e - { 3.14159265f, 0, -1, PAL_EPSILON, PAL_EPSILON * 10 }, // value: pi - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - sincosf_test1_validate( tests[i].value, tests[i].expected_sin, tests[i].expected_cos, tests[i].variance_sin, tests[i].variance_cos); - sincosf_test1_validate(-tests[i].value, -tests[i].expected_sin, tests[i].expected_cos, tests[i].variance_sin, tests[i].variance_cos); - } - - sincosf_test1_validate_isnan(PAL_NEGINF); - sincosf_test1_validate_isnan(PAL_NAN); - sincosf_test1_validate_isnan(PAL_POSINF); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/sinf/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/sinf/test1/test1.cpp deleted file mode 100644 index 1481843fed4735..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/sinf/test1/test1.cpp +++ /dev/null @@ -1,129 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that sinf return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabs -** -**===========================================================================*/ - -#include - -// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (6-9 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON -// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use -// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10. -#define PAL_EPSILON 4.76837158e-07 - -#define PAL_NAN sqrtf(-1.0f) -#define PAL_POSINF -logf(0.0f) -#define PAL_NEGINF logf(0.0f) - -/** - * Helper test structure - */ -struct test -{ - float value; /* value to test the function with */ - float expected; /* expected result */ - float variance; /* maximum delta between the expected and actual result */ -}; - -/** - * sinf_test1_validate - * - * test validation function - */ -void __cdecl sinf_test1_validate(float value, float expected, float variance) -{ - float result = sinf(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - float delta = fabsf(result - expected); - - if (delta > variance) - { - Fail("sinf(%g) returned %10.9g when it should have returned %10.9g", - value, result, expected); - } -} - -/** - * sinf_test1_validate - * - * test validation function for values returning NaN - */ -void __cdecl sinf_test1_validate_isnan(float value) -{ - float result = sinf(value); - - if (!_isnanf(result)) - { - Fail("sinf(%g) returned %10.9g when it should have returned %10.9g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -PALTEST(c_runtime_sinf_test1_paltest_sinf_test1, "c_runtime/sinf/test1/paltest_sinf_test1") -{ - struct test tests[] = - { - /* value expected variance */ - { 0, 0, PAL_EPSILON }, - { 0.318309886f, 0.312961796f, PAL_EPSILON }, // value: 1 / pi - { 0.434294482f, 0.420770483f, PAL_EPSILON }, // value: log10f(e) - { 0.636619772f, 0.594480769f, PAL_EPSILON }, // value: 2 / pi - { 0.693147181f, 0.638961276f, PAL_EPSILON }, // value: ln(2) - { 0.707106781f, 0.649636939f, PAL_EPSILON }, // value: 1 / sqrtf(2) - { 0.785398163f, 0.707106781f, PAL_EPSILON }, // value: pi / 4, expected: 1 / sqrtf(2) - { 1, 0.841470985f, PAL_EPSILON }, - { 1.12837917f, 0.903719457f, PAL_EPSILON }, // value: 2 / sqrtf(pi) - { 1.41421356f, 0.987765946f, PAL_EPSILON }, // value: sqrtf(2) - { 1.44269504f, 0.991806244f, PAL_EPSILON }, // value: logf2(e) - { 1.57079633f, 1, PAL_EPSILON * 10 }, // value: pi / 2 - { 2.30258509f, 0.743980337f, PAL_EPSILON }, // value: ln(10) - { 2.71828183f, 0.410781291f, PAL_EPSILON }, // value: e - { 3.14159265f, 0, PAL_EPSILON }, // value: pi - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - sinf_test1_validate( tests[i].value, tests[i].expected, tests[i].variance); - sinf_test1_validate(-tests[i].value, -tests[i].expected, tests[i].variance); - } - - sinf_test1_validate_isnan(PAL_NEGINF); - sinf_test1_validate_isnan(PAL_NAN); - sinf_test1_validate_isnan(PAL_POSINF); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/sinh/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/sinh/test1/test1.cpp deleted file mode 100644 index 2879bf16aea92e..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/sinh/test1/test1.cpp +++ /dev/null @@ -1,129 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that sinh return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabs -** -**===========================================================================*/ - -#include - -// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (15-17 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use -// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx -// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will -// use PAL_EPSILON * 10. -#define PAL_EPSILON 8.8817841970012523e-16 - -#define PAL_NAN sqrt(-1.0) -#define PAL_POSINF -log(0.0) -#define PAL_NEGINF log(0.0) - -/** - * Helper test structure - */ -struct test -{ - double value; /* value to test the function with */ - double expected; /* expected result */ - double variance; /* maximum delta between the expected and actual result */ -}; - -/** - * sinh_test1_validate - * - * test validation function - */ -void __cdecl sinh_test1_validate(double value, double expected, double variance) -{ - double result = sinh(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - double delta = fabs(result - expected); - - if (delta > variance) - { - Fail("sinh(%g) returned %20.17g when it should have returned %20.17g", - value, result, expected); - } -} - -/** - * sinh_test1_validate - * - * test validation function for values returning NaN - */ -void __cdecl sinh_test1_validate_isnan(double value) -{ - double result = sinh(value); - - if (!_isnan(result)) - { - Fail("sinh(%g) returned %20.17g when it should have returned %20.17g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -PALTEST(c_runtime_sinh_test1_paltest_sinh_test1, "c_runtime/sinh/test1/paltest_sinh_test1") -{ - struct test tests[] = - { - /* value expected variance */ - { 0, 0, PAL_EPSILON }, - { 0.31830988618379067, 0.32371243907207108, PAL_EPSILON }, // value: 1 / pi - { 0.43429448190325183, 0.44807597941469025, PAL_EPSILON }, // value: log10(e) - { 0.63661977236758134, 0.68050167815224332, PAL_EPSILON }, // value: 2 / pi - { 0.69314718055994531, 0.75, PAL_EPSILON }, // value: ln(2) - { 0.70710678118654752, 0.76752314512611633, PAL_EPSILON }, // value: 1 / sqrt(2) - { 0.78539816339744831, 0.86867096148600961, PAL_EPSILON }, // value: pi / 4 - { 1, 1.1752011936438015, PAL_EPSILON * 10 }, - { 1.1283791670955126, 1.3835428792038633, PAL_EPSILON * 10 }, // value: 2 / sqrt(pi) - { 1.4142135623730950, 1.9350668221743567, PAL_EPSILON * 10 }, // value: sqrt(2) - { 1.4426950408889634, 1.9978980091062796, PAL_EPSILON * 10 }, // value: log2(e) - { 1.5707963267948966, 2.3012989023072949, PAL_EPSILON * 10 }, // value: pi / 2 - { 2.3025850929940457, 4.95, PAL_EPSILON * 10 }, // value: ln(10) - { 2.7182818284590452, 7.5441371028169758, PAL_EPSILON * 10 }, // value: e - { 3.1415926535897932, 11.548739357257748, PAL_EPSILON * 100 }, // value: pi - { PAL_POSINF, PAL_POSINF, 0 }, - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - sinh_test1_validate( tests[i].value, tests[i].expected, tests[i].variance); - sinh_test1_validate(-tests[i].value, -tests[i].expected, tests[i].variance); - } - - sinh_test1_validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/sinhf/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/sinhf/test1/test1.cpp deleted file mode 100644 index a67ab96a4101e6..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/sinhf/test1/test1.cpp +++ /dev/null @@ -1,128 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that sinhf return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabs -** -**===========================================================================*/ - -#include - -// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (6-9 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON -// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use -// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10. -#define PAL_EPSILON 4.76837158e-07 - -#define PAL_NAN sqrtf(-1.0f) -#define PAL_POSINF -logf(0.0f) -#define PAL_NEGINF logf(0.0f) - -/** - * Helper test structure - */ -struct test -{ - float value; /* value to test the function with */ - float expected; /* expected result */ - float variance; /* maximum delta between the expected and actual result */ -}; - -/** - * sinhf_test1_validate - * - * test validation function - */ -void __cdecl sinhf_test1_validate(float value, float expected, float variance) -{ - float result = sinhf(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - float delta = fabsf(result - expected); - - if (delta > variance) - { - Fail("sinhf(%g) returned %10.9g when it should have returned %10.9g", - value, result, expected); - } -} - -/** - * sinhf_test1_validate - * - * test validation function for values returning NaN - */ -void __cdecl sinhf_test1_validate_isnan(float value) -{ - float result = sinhf(value); - - if (!_isnanf(result)) - { - Fail("sinhf(%g) returned %10.9g when it should have returned %10.9g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -PALTEST(c_runtime_sinhf_test1_paltest_sinhf_test1, "c_runtime/sinhf/test1/paltest_sinhf_test1") -{ - struct test tests[] = - { - /* value expected variance */ - { 0, 0, PAL_EPSILON }, - { 0.318309886f, 0.323712439f, PAL_EPSILON }, // value: 1 / pi - { 0.434294482f, 0.448075979f, PAL_EPSILON }, // value: log10f(e) - { 0.636619772f, 0.680501678f, PAL_EPSILON }, // value: 2 / pi - { 0.693147181f, 0.75, PAL_EPSILON }, // value: ln(2) - { 0.707106781f, 0.767523145f, PAL_EPSILON }, // value: 1 / sqrtf(2) - { 0.785398163f, 0.868670961f, PAL_EPSILON }, // value: pi / 4 - { 1, 1.17520119f, PAL_EPSILON * 10 }, - { 1.12837917f, 1.38354288f, PAL_EPSILON * 10 }, // value: 2 / sqrtf(pi) - { 1.41421356f, 1.93506682f, PAL_EPSILON * 10 }, // value: sqrtf(2) - { 1.44269504f, 1.99789801f, PAL_EPSILON * 10 }, // value: logf2(e) - { 1.57079633f, 2.30129890f, PAL_EPSILON * 10 }, // value: pi / 2 - { 2.30258509f, 4.95f, PAL_EPSILON * 10 }, // value: ln(10) - { 2.71828183f, 7.54413710f, PAL_EPSILON * 10 }, // value: e - { 3.14159265f, 11.5487394f, PAL_EPSILON * 100 }, // value: pi - { PAL_POSINF, PAL_POSINF, 0 }, - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - sinhf_test1_validate( tests[i].value, tests[i].expected, tests[i].variance); - sinhf_test1_validate(-tests[i].value, -tests[i].expected, tests[i].variance); - } - - sinhf_test1_validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/sqrt/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/sqrt/test1/test1.cpp deleted file mode 100644 index f61e51111f4981..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/sqrt/test1/test1.cpp +++ /dev/null @@ -1,122 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Call the sqrt function on a positive value, a positive value -** with a decimal and on the maximum possible double value. -** -** -**===================================================================*/ - -#include - -// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (15-17 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use -// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx -// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will -// use PAL_EPSILON * 10. -#define PAL_EPSILON 8.8817841970012523e-16 - -#define PAL_NAN sqrt(-1.0) -#define PAL_POSINF -log(0.0) -#define PAL_NEGINF log(0.0) - -/** - * Helper test structure - */ -struct test -{ - double value; /* value to test the function with */ - double expected; /* expected result */ - double variance; /* maximum delta between the expected and actual result */ -}; - -/** - * sqrt_test1_validate - * - * test validation function - */ -void __cdecl sqrt_test1_validate(double value, double expected, double variance) -{ - double result = sqrt(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - double delta = fabs(result - expected); - - if (delta > variance) - { - Fail("sqrt(%g) returned %20.17g when it should have returned %20.17g", - value, result, expected); - } -} - -/** - * sqrt_test1_validate - * - * test validation function for values returning NaN - */ -void __cdecl sqrt_test1_validate_isnan(double value) -{ - double result = sqrt(value); - - if (!_isnan(result)) - { - Fail("sqrt(%g) returned %20.17g when it should have returned %20.17g", - value, result, PAL_NAN); - } -} - -PALTEST(c_runtime_sqrt_test1_paltest_sqrt_test1, "c_runtime/sqrt/test1/paltest_sqrt_test1") -{ - struct test tests[] = - { - /* value expected variance */ - { 0.31830988618379067, 0.56418958354775629, PAL_EPSILON }, // value: 1 / pi - { 0.43429448190325183, 0.65901022898226081, PAL_EPSILON }, // value: log10(e) - { 0.63661977236758134, 0.79788456080286536, PAL_EPSILON }, // value: 2 / pi - { 0.69314718055994531, 0.83255461115769776, PAL_EPSILON }, // value: ln(2) - { 0.70710678118654752, 0.84089641525371454, PAL_EPSILON }, // value: 1 / sqrt(2) - { 0.78539816339744831, 0.88622692545275801, PAL_EPSILON }, // value: pi / 4 - { 1, 1, PAL_EPSILON * 10 }, - { 1.1283791670955126, 1.0622519320271969, PAL_EPSILON * 10 }, // value: 2 / sqrt(pi) - { 1.4142135623730950, 1.1892071150027211, PAL_EPSILON * 10 }, // value: sqrt(2) - { 1.4426950408889634, 1.2011224087864498, PAL_EPSILON * 10 }, // value: log2(e) - { 1.5707963267948966, 1.2533141373155003, PAL_EPSILON * 10 }, // value: pi / 2 - { 2.3025850929940457, 1.5174271293851464, PAL_EPSILON * 10 }, // value: ln(10) - { 2.7182818284590452, 1.6487212707001281, PAL_EPSILON * 10 }, // value: e - { 3.1415926535897932, 1.7724538509055160, PAL_EPSILON * 10 }, // value: pi - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - sqrt_test1_validate(-0.0, -0.0, PAL_EPSILON); - sqrt_test1_validate( 0.0, 0.0, PAL_EPSILON); - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - sqrt_test1_validate(tests[i].value, tests[i].expected, tests[i].variance); - sqrt_test1_validate_isnan(-tests[i].value); - } - - sqrt_test1_validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/sqrtf/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/sqrtf/test1/test1.cpp deleted file mode 100644 index 821ae42750cfdb..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/sqrtf/test1/test1.cpp +++ /dev/null @@ -1,121 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Call the sqrtf function on a positive value, a positive value -** with a decimal and on the maximum possible float value. -** -** -**===================================================================*/ - -#include - -// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (6-9 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON -// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use -// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10. -#define PAL_EPSILON 4.76837158e-07 - -#define PAL_NAN sqrtf(-1.0f) -#define PAL_POSINF -logf(0.0f) -#define PAL_NEGINF logf(0.0f) - -/** - * Helper test structure - */ -struct test -{ - float value; /* value to test the function with */ - float expected; /* expected result */ - float variance; /* maximum delta between the expected and actual result */ -}; - -/** - * sqrtf_test1_validate - * - * test validation function - */ -void __cdecl sqrtf_test1_validate(float value, float expected, float variance) -{ - float result = sqrtf(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - float delta = fabsf(result - expected); - - if (delta > variance) - { - Fail("sqrtf(%g) returned %10.9g when it should have returned %10.9g", - value, result, expected); - } -} - -/** - * sqrtf_test1_validate - * - * test validation function for values returning NaN - */ -void __cdecl sqrtf_test1_validate_isnan(float value) -{ - float result = sqrtf(value); - - if (!_isnanf(result)) - { - Fail("sqrtf(%g) returned %10.9g when it should have returned %10.9g", - value, result, PAL_NAN); - } -} - -PALTEST(c_runtime_sqrtf_test1_paltest_sqrtf_test1, "c_runtime/sqrtf/test1/paltest_sqrtf_test1") -{ - struct test tests[] = - { - /* value expected variance */ - { 0.318309886f, 0.564189584f, PAL_EPSILON }, // value: 1 / pi - { 0.434294482f, 0.659010229f, PAL_EPSILON }, // value: log10f(e) - { 0.636619772f, 0.797884561f, PAL_EPSILON }, // value: 2 / pi - { 0.693147181f, 0.832554611f, PAL_EPSILON }, // value: ln(2) - { 0.707106781f, 0.840896415f, PAL_EPSILON }, // value: 1 / sqrtf(2) - { 0.785398163f, 0.886226925f, PAL_EPSILON }, // value: pi / 4 - { 1, 1, PAL_EPSILON * 10 }, - { 1.12837917f, 1.06225193f, PAL_EPSILON * 10 }, // value: 2 / sqrtf(pi) - { 1.41421356f, 1.18920712f, PAL_EPSILON * 10 }, // value: sqrtf(2) - { 1.44269504f, 1.20112241f, PAL_EPSILON * 10 }, // value: logf2(e) - { 1.57079633f, 1.25331414f, PAL_EPSILON * 10 }, // value: pi / 2 - { 2.30258509f, 1.51742713f, PAL_EPSILON * 10 }, // value: ln(10) - { 2.71828183f, 1.64872127f, PAL_EPSILON * 10 }, // value: e - { 3.14159265f, 1.77245385F, PAL_EPSILON * 10 }, // value: pi - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - sqrtf_test1_validate(-0.0f, -0.0f, PAL_EPSILON); - sqrtf_test1_validate( 0.0f, 0.0f, PAL_EPSILON); - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - sqrtf_test1_validate(tests[i].value, tests[i].expected, tests[i].variance); - sqrtf_test1_validate_isnan(-tests[i].value); - } - - sqrtf_test1_validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/tan/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/tan/test1/test1.cpp deleted file mode 100644 index 11f9123354ea24..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/tan/test1/test1.cpp +++ /dev/null @@ -1,136 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that tan return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabs -** -**===========================================================================*/ - -#include - -// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (15-17 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use -// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx -// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will -// use PAL_EPSILON * 10. -#define PAL_EPSILON 8.8817841970012523e-16 - -#define PAL_NAN sqrt(-1.0) -#define PAL_POSINF -log(0.0) -#define PAL_NEGINF log(0.0) - -/** - * Helper test structure - */ -struct test -{ - double value; /* value to test the function with */ - double expected; /* expected result */ - double variance; /* maximum delta between the expected and actual result */ -}; - -/** - * tan_test1_validate - * - * test validation function - */ -void __cdecl tan_test1_validate(double value, double expected, double variance) -{ - double result = tan(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - double delta = fabs(result - expected); - - if (delta > variance) - { - Fail("tan(%g) returned %20.17g when it should have returned %20.17g", - value, result, expected); - } -} - -/** - * tan_test1_validate - * - * test validation function for values returning NaN - */ -void __cdecl tan_test1_validate_isnan(double value) -{ - double result = tan(value); - - if (!_isnan(result)) - { - Fail("tan(%g) returned %20.17g when it should have returned %20.17g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -PALTEST(c_runtime_tan_test1_paltest_tan_test1, "c_runtime/tan/test1/paltest_tan_test1") -{ - struct test tests[] = - { - /* value expected variance */ - { 0, 0, PAL_EPSILON }, - { 0.31830988618379067, 0.32951473309607836, PAL_EPSILON }, // value: 1 / pi - { 0.43429448190325183, 0.46382906716062964, PAL_EPSILON }, // value: log10(e) - { 0.63661977236758134, 0.73930295048660405, PAL_EPSILON }, // value: 2 / pi - { 0.69314718055994531, 0.83064087786078395, PAL_EPSILON }, // value: ln(2) - { 0.70710678118654752, 0.85451043200960189, PAL_EPSILON }, // value: 1 / sqrt(2) - { 0.78539816339744831, 1, PAL_EPSILON * 10 }, // value: pi / 4 - { 1, 1.5574077246549022, PAL_EPSILON * 10 }, - { 1.1283791670955126, 2.1108768356626451, PAL_EPSILON * 10 }, // value: 2 / sqrt(pi) - { 1.4142135623730950, 6.3341191670421916, PAL_EPSILON * 10 }, // value: sqrt(2) - { 1.4426950408889634, 7.7635756709721848, PAL_EPSILON * 10 }, // value: log2(e) - // SEE BELOW -- { 1.5707963267948966, PAL_POSINF, 0 }, // value: pi / 2 - { 2.3025850929940457, -1.1134071468135374, PAL_EPSILON * 10 }, // value: ln(10) - { 2.7182818284590452, -0.45054953406980750, PAL_EPSILON }, // value: e - { 3.1415926535897932, 0, PAL_EPSILON }, // value: pi - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - tan_test1_validate( tests[i].value, tests[i].expected, tests[i].variance); - tan_test1_validate(-tests[i].value, -tests[i].expected, tests[i].variance); - } - - // -- SPECIAL CASE -- - // Normally, tan(pi / 2) would return PAL_POSINF (atan2(PAL_POSINF) does return (pi / 2)). - // However, it seems instead (on all supported systems), we get a different number entirely. - tan_test1_validate( 1.5707963267948966, 16331239353195370.0, 0); - tan_test1_validate(-1.5707963267948966, -16331239353195370.0, 0); - - tan_test1_validate_isnan(PAL_NEGINF); - tan_test1_validate_isnan(PAL_NAN); - tan_test1_validate_isnan(PAL_POSINF); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/tanf/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/tanf/test1/test1.cpp deleted file mode 100644 index 2f7358cc2774dc..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/tanf/test1/test1.cpp +++ /dev/null @@ -1,135 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that tanf return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabs -** -**===========================================================================*/ - -#include - -// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (6-9 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON -// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use -// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10. -#define PAL_EPSILON 4.76837158e-07 - -#define PAL_NAN sqrtf(-1.0f) -#define PAL_POSINF -logf(0.0f) -#define PAL_NEGINF logf(0.0f) - -/** - * Helper test structure - */ -struct test -{ - float value; /* value to test the function with */ - float expected; /* expected result */ - float variance; /* maximum delta between the expected and actual result */ -}; - -/** - * tanf_test1_validate - * - * test validation function - */ -void __cdecl tanf_test1_validate(float value, float expected, float variance) -{ - float result = tanf(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - float delta = fabsf(result - expected); - - if (delta > variance) - { - Fail("tanf(%g) returned %10.9g when it should have returned %10.9g", - value, result, expected); - } -} - -/** - * tanf_test1_validate - * - * test validation function for values returning NaN - */ -void __cdecl tanf_test1_validate_isnan(float value) -{ - float result = tanf(value); - - if (!_isnanf(result)) - { - Fail("tanf(%g) returned %10.9g when it should have returned %10.9g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -PALTEST(c_runtime_tanf_test1_paltest_tanf_test1, "c_runtime/tanf/test1/paltest_tanf_test1") -{ - struct test tests[] = - { - /* value expected variance */ - { 0, 0, PAL_EPSILON }, - { 0.318309886f, 0.329514733f, PAL_EPSILON }, // value: 1 / pi - { 0.434294482f, 0.463829067f, PAL_EPSILON }, // value: log10f(e) - { 0.636619772f, 0.739302950f, PAL_EPSILON }, // value: 2 / pi - { 0.693147181f, 0.830640878f, PAL_EPSILON }, // value: ln(2) - { 0.707106781f, 0.854510432f, PAL_EPSILON }, // value: 1 / sqrtf(2) - { 0.785398163f, 1, PAL_EPSILON * 10 }, // value: pi / 4 - { 1, 1.55740772f, PAL_EPSILON * 10 }, - { 1.12837917f, 2.11087684f, PAL_EPSILON * 10 }, // value: 2 / sqrtf(pi) - { 1.41421356f, 6.33411917f, PAL_EPSILON * 10 }, // value: sqrtf(2) - { 1.44269504f, 7.76357567f, PAL_EPSILON * 10 }, // value: logf2(e) - // SEE BELOW -- { 1.57079633f, PAL_POSINF, 0 }, // value: pi / 2 - { 2.30258509f, -1.11340715f, PAL_EPSILON * 10 }, // value: ln(10) - { 2.71828183f, -0.450549534f, PAL_EPSILON }, // value: e - { 3.14159265f, 0, PAL_EPSILON }, // value: pi - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - tanf_test1_validate( tests[i].value, tests[i].expected, tests[i].variance); - tanf_test1_validate(-tests[i].value, -tests[i].expected, tests[i].variance); - } - - // -- SPECIAL CASE -- - // Normally, tanf(pi / 2) would return PAL_POSINF (atan2f(PAL_POSINF) does return (pi / 2)). - // However, it seems instead (on all supported systems), we get a different number entirely. - tanf_test1_validate( 1.57079633f, -22877332.0, PAL_EPSILON * 100000000); - tanf_test1_validate(-1.57079633f, 22877332.0, PAL_EPSILON * 100000000); - - tanf_test1_validate_isnan(PAL_NEGINF); - tanf_test1_validate_isnan(PAL_NAN); - tanf_test1_validate_isnan(PAL_POSINF); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/tanh/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/tanh/test1/test1.cpp deleted file mode 100644 index a2df3885803c04..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/tanh/test1/test1.cpp +++ /dev/null @@ -1,129 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that tanh return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabs -** -**===========================================================================*/ - -#include - -// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (15-17 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use -// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx -// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will -// use PAL_EPSILON * 10. -#define PAL_EPSILON 8.8817841970012523e-16 - -#define PAL_NAN sqrt(-1.0) -#define PAL_POSINF -log(0.0) -#define PAL_NEGINF log(0.0) - -/** - * Helper test structure - */ -struct test -{ - double value; /* value to test the function with */ - double expected; /* expected result */ - double variance; /* maximum delta between the expected and actual result */ -}; - -/** - * tanh_test1_validate - * - * test validation function - */ -void __cdecl tanh_test1_validate(double value, double expected, double variance) -{ - double result = tanh(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - double delta = fabs(result - expected); - - if (delta > variance) - { - Fail("tanh(%g) returned %20.17g when it should have returned %20.17g", - value, result, expected); - } -} - -/** - * tanh_test1_validate - * - * test validation function for values returning NaN - */ -void __cdecl tanh_test1_validate_isnan(double value) -{ - double result = tanh(value); - - if (!_isnan(result)) - { - Fail("tanh(%g) returned %20.17g when it should have returned %20.17g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -PALTEST(c_runtime_tanh_test1_paltest_tanh_test1, "c_runtime/tanh/test1/paltest_tanh_test1") -{ - struct test tests[] = - { - /* value expected variance */ - { 0, 0, PAL_EPSILON }, - { 0.31830988618379067, 0.30797791269089433, PAL_EPSILON }, // value: 1 / pi - { 0.43429448190325183, 0.40890401183401433, PAL_EPSILON }, // value: log10(e) - { 0.63661977236758134, 0.56259360033158334, PAL_EPSILON }, // value: 2 / pi - { 0.69314718055994531, 0.6, PAL_EPSILON }, // value: ln(2) - { 0.70710678118654752, 0.60885936501391381, PAL_EPSILON }, // value: 1 / sqrt(2) - { 0.78539816339744831, 0.65579420263267244, PAL_EPSILON }, // value: pi / 4 - { 1, 0.76159415595576489, PAL_EPSILON }, - { 1.1283791670955126, 0.81046380599898809, PAL_EPSILON }, // value: 2 / sqrt(pi) - { 1.4142135623730950, 0.88838556158566054, PAL_EPSILON }, // value: sqrt(2) - { 1.4426950408889634, 0.89423894585503855, PAL_EPSILON }, // value: log2(e) - { 1.5707963267948966, 0.91715233566727435, PAL_EPSILON }, // value: pi / 2 - { 2.3025850929940457, 0.98019801980198020, PAL_EPSILON }, // value: ln(10) - { 2.7182818284590452, 0.99132891580059984, PAL_EPSILON }, // value: e - { 3.1415926535897932, 0.99627207622074994, PAL_EPSILON }, // value: pi - { PAL_POSINF, 1, PAL_EPSILON * 10 } - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - tanh_test1_validate( tests[i].value, tests[i].expected, tests[i].variance); - tanh_test1_validate(-tests[i].value, -tests[i].expected, tests[i].variance); - } - - tanh_test1_validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/tanhf/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/tanhf/test1/test1.cpp deleted file mode 100644 index 646e743fa418bf..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/tanhf/test1/test1.cpp +++ /dev/null @@ -1,128 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that tanhf return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabs -** -**===========================================================================*/ - -#include - -// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (6-9 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON -// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use -// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10. -#define PAL_EPSILON 4.76837158e-07 - -#define PAL_NAN sqrtf(-1.0f) -#define PAL_POSINF -logf(0.0f) -#define PAL_NEGINF logf(0.0f) - -/** - * Helper test structure - */ -struct test -{ - float value; /* value to test the function with */ - float expected; /* expected result */ - float variance; /* maximum delta between the expected and actual result */ -}; - -/** - * tanhf_test1_validate - * - * test validation function - */ -void __cdecl tanhf_test1_validate(float value, float expected, float variance) -{ - float result = tanhf(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - float delta = fabsf(result - expected); - - if (delta > variance) - { - Fail("tanhf(%g) returned %10.9g when it should have returned %10.9g", - value, result, expected); - } -} - -/** - * tanhf_test1_validate - * - * test validation function for values returning NaN - */ -void __cdecl tanhf_test1_validate_isnan(float value) -{ - float result = tanhf(value); - - if (!_isnanf(result)) - { - Fail("tanhf(%g) returned %10.9g when it should have returned %10.9g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -PALTEST(c_runtime_tanhf_test1_paltest_tanhf_test1, "c_runtime/tanhf/test1/paltest_tanhf_test1") -{ - struct test tests[] = - { - /* value expected variance */ - { 0, 0, PAL_EPSILON }, - { 0.318309886f, 0.307977913f, PAL_EPSILON }, // value: 1 / pi - { 0.434294482f, 0.408904012f, PAL_EPSILON }, // value: log10f(e) - { 0.636619772f, 0.562593600f, PAL_EPSILON }, // value: 2 / pi - { 0.693147181f, 0.6f, PAL_EPSILON }, // value: ln(2) - { 0.707106781f, 0.608859365f, PAL_EPSILON }, // value: 1 / sqrtf(2) - { 0.785398163f, 0.655794203f, PAL_EPSILON }, // value: pi / 4 - { 1, 0.761594156f, PAL_EPSILON }, - { 1.12837917f, 0.810463806f, PAL_EPSILON }, // value: 2 / sqrtf(pi) - { 1.41421356f, 0.888385562f, PAL_EPSILON }, // value: sqrtf(2) - { 1.44269504f, 0.894238946f, PAL_EPSILON }, // value: logf2(e) - { 1.57079633f, 0.917152336f, PAL_EPSILON }, // value: pi / 2 - { 2.30258509f, 0.980198020f, PAL_EPSILON }, // value: ln(10) - { 2.71828183f, 0.991328916f, PAL_EPSILON }, // value: e - { 3.14159265f, 0.996272076f, PAL_EPSILON }, // value: pi - { PAL_POSINF, 1, PAL_EPSILON * 10 } - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - tanhf_test1_validate( tests[i].value, tests[i].expected, tests[i].variance); - tanhf_test1_validate(-tests[i].value, -tests[i].expected, tests[i].variance); - } - - tanhf_test1_validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/common/palsuite.h b/src/coreclr/pal/tests/palsuite/common/palsuite.h index c275b3812a256c..640a458232c69f 100644 --- a/src/coreclr/pal/tests/palsuite/common/palsuite.h +++ b/src/coreclr/pal/tests/palsuite/common/palsuite.h @@ -1,4 +1,3 @@ -// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /*============================================================================ diff --git a/src/coreclr/pal/tests/palsuite/compilableTests.txt b/src/coreclr/pal/tests/palsuite/compilableTests.txt index b96903dbc44d12..0722dfc810a705 100644 --- a/src/coreclr/pal/tests/palsuite/compilableTests.txt +++ b/src/coreclr/pal/tests/palsuite/compilableTests.txt @@ -1,18 +1,3 @@ -c_runtime/abs/test1/paltest_abs_test1 -c_runtime/acos/test1/paltest_acos_test1 -c_runtime/acosf/test1/paltest_acosf_test1 -c_runtime/acosh/test1/paltest_acosh_test1 -c_runtime/acoshf/test1/paltest_acoshf_test1 -c_runtime/asin/test1/paltest_asin_test1 -c_runtime/asinf/test1/paltest_asinf_test1 -c_runtime/asinh/test1/paltest_asinh_test1 -c_runtime/asinhf/test1/paltest_asinhf_test1 -c_runtime/atan/test1/paltest_atan_test1 -c_runtime/atan2/test1/paltest_atan2_test1 -c_runtime/atan2f/test1/paltest_atan2f_test1 -c_runtime/atanf/test1/paltest_atanf_test1 -c_runtime/atanh/test1/paltest_atanh_test1 -c_runtime/atanhf/test1/paltest_atanhf_test1 c_runtime/atof/test1/paltest_atof_test1 c_runtime/atoi/test1/paltest_atoi_test1 c_runtime/bsearch/test1/paltest_bsearch_test1 @@ -29,22 +14,12 @@ c_runtime/errno/test1/paltest_errno_test1 c_runtime/errno/test2/paltest_errno_test2 c_runtime/exit/test1/paltest_exit_test1 c_runtime/exit/test2/paltest_exit_test2 -c_runtime/exp/test1/paltest_exp_test1 -c_runtime/expf/test1/paltest_expf_test1 -c_runtime/fabs/test1/paltest_fabs_test1 -c_runtime/fabsf/test1/paltest_fabsf_test1 c_runtime/ferror/test1/paltest_ferror_test1 c_runtime/ferror/test2/paltest_ferror_test2 c_runtime/fflush/test1/paltest_fflush_test1 c_runtime/fgets/test1/paltest_fgets_test1 c_runtime/fgets/test2/paltest_fgets_test2 c_runtime/fgets/test3/paltest_fgets_test3 -c_runtime/floor/test1/paltest_floor_test1 -c_runtime/floorf/test1/paltest_floorf_test1 -c_runtime/fma/test1/paltest_fma_test1 -c_runtime/fmaf/test1/paltest_fmaf_test1 -c_runtime/fmod/test1/paltest_fmod_test1 -c_runtime/fmodf/test1/paltest_fmodf_test1 c_runtime/fopen/test1/paltest_fopen_test1 c_runtime/fopen/test2/paltest_fopen_test2 c_runtime/fopen/test3/paltest_fopen_test3 @@ -61,8 +36,6 @@ c_runtime/free/test1/paltest_free_test1 c_runtime/fseek/test1/paltest_fseek_test1 c_runtime/ftell/test1/paltest_ftell_test1 c_runtime/fwrite/test1/paltest_fwrite_test1 -c_runtime/ilogb/test1/paltest_ilogb_test1 -c_runtime/ilogbf/test1/paltest_ilogbf_test1 c_runtime/isalnum/test1/paltest_isalnum_test1 c_runtime/isalpha/test1/paltest_isalpha_test1 c_runtime/isdigit/test1/paltest_isdigit_test1 @@ -74,34 +47,16 @@ c_runtime/iswspace/test1/paltest_iswspace_test1 c_runtime/iswupper/test1/paltest_iswupper_test1 c_runtime/isxdigit/test1/paltest_isxdigit_test1 c_runtime/llabs/test1/paltest_llabs_test1 -c_runtime/log/test1/paltest_log_test1 -c_runtime/log10/test1/paltest_log10_test1 -c_runtime/log10f/test1/paltest_log10f_test1 -c_runtime/log2/test1/paltest_log2_test1 -c_runtime/log2f/test1/paltest_log2f_test1 -c_runtime/logf/test1/paltest_logf_test1 c_runtime/malloc/test1/paltest_malloc_test1 c_runtime/malloc/test2/paltest_malloc_test2 c_runtime/memchr/test1/paltest_memchr_test1 c_runtime/memcmp/test1/paltest_memcmp_test1 c_runtime/memmove/test1/paltest_memmove_test1 c_runtime/memset/test1/paltest_memset_test1 -c_runtime/modf/test1/paltest_modf_test1 -c_runtime/modff/test1/paltest_modff_test1 -c_runtime/pow/test1/paltest_pow_test1 -c_runtime/powf/test1/paltest_powf_test1 c_runtime/qsort/test1/paltest_qsort_test1 c_runtime/qsort/test2/paltest_qsort_test2 c_runtime/rand_srand/test1/paltest_rand_srand_test1 c_runtime/realloc/test1/paltest_realloc_test1 -c_runtime/sin/test1/paltest_sin_test1 -c_runtime/sincos/test1/paltest_sincos_test1 -c_runtime/sincosf/test1/paltest_sincosf_test1 -c_runtime/sinf/test1/paltest_sinf_test1 -c_runtime/sinh/test1/paltest_sinh_test1 -c_runtime/sinhf/test1/paltest_sinhf_test1 -c_runtime/sqrt/test1/paltest_sqrt_test1 -c_runtime/sqrtf/test1/paltest_sqrtf_test1 c_runtime/sscanf_s/test1/paltest_sscanf_test1 c_runtime/sscanf_s/test10/paltest_sscanf_test10 c_runtime/sscanf_s/test11/paltest_sscanf_test11 @@ -134,10 +89,6 @@ c_runtime/strtod/test1/paltest_strtod_test1 c_runtime/strtod/test2/paltest_strtod_test2 c_runtime/strtok/test1/paltest_strtok_test1 c_runtime/strtoul/test1/paltest_strtoul_test1 -c_runtime/tan/test1/paltest_tan_test1 -c_runtime/tanf/test1/paltest_tanf_test1 -c_runtime/tanh/test1/paltest_tanh_test1 -c_runtime/tanhf/test1/paltest_tanhf_test1 c_runtime/time/test1/paltest_time_test1 c_runtime/tolower/test1/paltest_tolower_test1 c_runtime/toupper/test1/paltest_toupper_test1 diff --git a/src/coreclr/pal/tests/palsuite/paltestlist.txt b/src/coreclr/pal/tests/palsuite/paltestlist.txt index 7491006cc7e607..60ad2f131dd37f 100644 --- a/src/coreclr/pal/tests/palsuite/paltestlist.txt +++ b/src/coreclr/pal/tests/palsuite/paltestlist.txt @@ -1,47 +1,16 @@ -c_runtime/abs/test1/paltest_abs_test1 -c_runtime/acos/test1/paltest_acos_test1 -c_runtime/acosf/test1/paltest_acosf_test1 -c_runtime/acosh/test1/paltest_acosh_test1 -c_runtime/acoshf/test1/paltest_acoshf_test1 -c_runtime/asin/test1/paltest_asin_test1 -c_runtime/asinf/test1/paltest_asinf_test1 -c_runtime/asinh/test1/paltest_asinh_test1 -c_runtime/asinhf/test1/paltest_asinhf_test1 -c_runtime/atan/test1/paltest_atan_test1 -c_runtime/atan2/test1/paltest_atan2_test1 -c_runtime/atan2f/test1/paltest_atan2f_test1 -c_runtime/atanf/test1/paltest_atanf_test1 -c_runtime/atanh/test1/paltest_atanh_test1 -c_runtime/atanhf/test1/paltest_atanhf_test1 c_runtime/atof/test1/paltest_atof_test1 c_runtime/atoi/test1/paltest_atoi_test1 c_runtime/bsearch/test1/paltest_bsearch_test1 c_runtime/bsearch/test2/paltest_bsearch_test2 -c_runtime/cbrt/test1/paltest_cbrt_test1 -c_runtime/cbrtf/test1/paltest_cbrtf_test1 -c_runtime/ceil/test1/paltest_ceil_test1 -c_runtime/ceilf/test1/paltest_ceilf_test1 -c_runtime/cos/test1/paltest_cos_test1 -c_runtime/cosf/test1/paltest_cosf_test1 -c_runtime/cosh/test1/paltest_cosh_test1 -c_runtime/coshf/test1/paltest_coshf_test1 c_runtime/errno/test1/paltest_errno_test1 c_runtime/errno/test2/paltest_errno_test2 c_runtime/exit/test1/paltest_exit_test1 -c_runtime/exp/test1/paltest_exp_test1 -c_runtime/expf/test1/paltest_expf_test1 -c_runtime/fabs/test1/paltest_fabs_test1 -c_runtime/fabsf/test1/paltest_fabsf_test1 c_runtime/fflush/test1/paltest_fflush_test1 c_runtime/fgets/test1/paltest_fgets_test1 c_runtime/fgets/test2/paltest_fgets_test2 c_runtime/fgets/test3/paltest_fgets_test3 c_runtime/floor/test1/paltest_floor_test1 c_runtime/floorf/test1/paltest_floorf_test1 -c_runtime/fma/test1/paltest_fma_test1 -c_runtime/fmaf/test1/paltest_fmaf_test1 -c_runtime/fmod/test1/paltest_fmod_test1 -c_runtime/fmodf/test1/paltest_fmodf_test1 c_runtime/fopen/test1/paltest_fopen_test1 c_runtime/fopen/test2/paltest_fopen_test2 c_runtime/fopen/test3/paltest_fopen_test3 @@ -53,8 +22,6 @@ c_runtime/fputs/test1/paltest_fputs_test1 c_runtime/free/test1/paltest_free_test1 c_runtime/fseek/test1/paltest_fseek_test1 c_runtime/fwrite/test1/paltest_fwrite_test1 -c_runtime/ilogb/test1/paltest_ilogb_test1 -c_runtime/ilogbf/test1/paltest_ilogbf_test1 c_runtime/isalnum/test1/paltest_isalnum_test1 c_runtime/isalpha/test1/paltest_isalpha_test1 c_runtime/isdigit/test1/paltest_isdigit_test1 @@ -67,11 +34,6 @@ c_runtime/iswupper/test1/paltest_iswupper_test1 c_runtime/isxdigit/test1/paltest_isxdigit_test1 c_runtime/llabs/test1/paltest_llabs_test1 c_runtime/log/test1/paltest_log_test1 -c_runtime/log2/test1/paltest_log2_test1 -c_runtime/log2f/test1/paltest_log2f_test1 -c_runtime/log10/test1/paltest_log10_test1 -c_runtime/log10f/test1/paltest_log10f_test1 -c_runtime/logf/test1/paltest_logf_test1 c_runtime/malloc/test1/paltest_malloc_test1 c_runtime/malloc/test2/paltest_malloc_test2 c_runtime/memchr/test1/paltest_memchr_test1 @@ -80,20 +42,10 @@ c_runtime/memmove/test1/paltest_memmove_test1 c_runtime/memset/test1/paltest_memset_test1 c_runtime/modf/test1/paltest_modf_test1 c_runtime/modff/test1/paltest_modff_test1 -c_runtime/pow/test1/paltest_pow_test1 -c_runtime/powf/test1/paltest_powf_test1 c_runtime/qsort/test1/paltest_qsort_test1 c_runtime/qsort/test2/paltest_qsort_test2 c_runtime/rand_srand/test1/paltest_rand_srand_test1 c_runtime/realloc/test1/paltest_realloc_test1 -c_runtime/sin/test1/paltest_sin_test1 -c_runtime/sincos/test1/paltest_sincos_test1 -c_runtime/sincosf/test1/paltest_sincosf_test1 -c_runtime/sinf/test1/paltest_sinf_test1 -c_runtime/sinh/test1/paltest_sinh_test1 -c_runtime/sinhf/test1/paltest_sinhf_test1 -c_runtime/sqrt/test1/paltest_sqrt_test1 -c_runtime/sqrtf/test1/paltest_sqrtf_test1 c_runtime/sscanf_s/test1/paltest_sscanf_test1 c_runtime/sscanf_s/test10/paltest_sscanf_test10 c_runtime/sscanf_s/test11/paltest_sscanf_test11 @@ -126,10 +78,6 @@ c_runtime/strtod/test1/paltest_strtod_test1 c_runtime/strtod/test2/paltest_strtod_test2 c_runtime/strtok/test1/paltest_strtok_test1 c_runtime/strtoul/test1/paltest_strtoul_test1 -c_runtime/tan/test1/paltest_tan_test1 -c_runtime/tanf/test1/paltest_tanf_test1 -c_runtime/tanh/test1/paltest_tanh_test1 -c_runtime/tanhf/test1/paltest_tanhf_test1 c_runtime/time/test1/paltest_time_test1 c_runtime/tolower/test1/paltest_tolower_test1 c_runtime/toupper/test1/paltest_toupper_test1 diff --git a/src/native/corehost/apphost/static/CMakeLists.txt b/src/native/corehost/apphost/static/CMakeLists.txt index 7a14c7c92ed668..03e7e7a6559eb6 100644 --- a/src/native/corehost/apphost/static/CMakeLists.txt +++ b/src/native/corehost/apphost/static/CMakeLists.txt @@ -118,6 +118,8 @@ if(CLR_CMAKE_TARGET_WIN32) System.Globalization.Native-Static System.IO.Compression.Native-Static + netintrinsics + kernel32.lib advapi32.lib ole32.lib @@ -148,6 +150,8 @@ else() System.Native-Static System.Security.Cryptography.Native.OpenSsl-Static + netintrinsics + palrt coreclrpal_dac corguids diff --git a/src/native/netintrinsics/CMakeLists.txt b/src/native/netintrinsics/CMakeLists.txt new file mode 100644 index 00000000000000..57f504f7b2c11c --- /dev/null +++ b/src/native/netintrinsics/CMakeLists.txt @@ -0,0 +1,8 @@ +set(SOURCES math.c) + +include(configure.cmake) + +add_library(netintrinsics OBJECT ${SOURCES}) + +target_include_directories(netintrinsics PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) +target_include_directories(netintrinsics PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) \ No newline at end of file diff --git a/src/native/netintrinsics/config.h.in b/src/native/netintrinsics/config.h.in new file mode 100644 index 00000000000000..18e78b33f5253a --- /dev/null +++ b/src/native/netintrinsics/config.h.in @@ -0,0 +1,17 @@ +#ifndef NETINTRINSICS_CONFIG_H_INCLUDED +#define NETINTRINSICS_CONFIG_H_INCLUDED + +#cmakedefine01 HAVE_IEEEFP_H +#cmakedefine01 HAVE_COMPATIBLE_ACOS +#cmakedefine01 HAVE_COMPATIBLE_ASIN +#cmakedefine01 HAVE_COMPATIBLE_POW +#cmakedefine01 HAVE_VALID_NEGATIVE_INF_POW +#cmakedefine01 HAVE_VALID_POSITIVE_INF_POW +#cmakedefine01 HAVE_COMPATIBLE_ATAN2 +#cmakedefine01 HAVE_COMPATIBLE_EXP +#cmakedefine01 HAVE_COMPATIBLE_ILOGB0 +#cmakedefine01 HAVE_COMPATIBLE_ILOGBNAN +#cmakedefine01 HAVE_COMPATIBLE_LOG +#cmakedefine01 HAVE_COMPATIBLE_LOG10 + +#endif // NETINTRINSICS_CONFIG_H_INCLUDED diff --git a/src/native/netintrinsics/configure.cmake b/src/native/netintrinsics/configure.cmake new file mode 100644 index 00000000000000..6eb29ba7b174f9 --- /dev/null +++ b/src/native/netintrinsics/configure.cmake @@ -0,0 +1,200 @@ +include(CheckCSourceRuns) +include(CheckIncludeFile) + +if(CLR_CMAKE_TARGET_FREEBSD) + set(CMAKE_REQUIRED_INCLUDES ${CROSS_ROOTFS}/usr/local/include) +elseif(CLR_CMAKE_TARGET_SUNOS) + set(CMAKE_REQUIRED_INCLUDES /opt/local/include) +endif() + +check_include_files(ieeefp.h HAVE_IEEEFP_H) + +set(CMAKE_REQUIRED_LIBRARIES m) +check_c_source_runs(" +#include +#include + +int main(void) { + volatile double x = 10; + if (!isnan(acos(x))) { + exit(1); + } + exit(0); +}" HAVE_COMPATIBLE_ACOS) +check_c_source_runs(" +#include +#include + +int main(void) { + volatile double arg = 10; + if (!isnan(asin(arg))) { + exit(1); + } + exit(0); +}" HAVE_COMPATIBLE_ASIN) +check_c_source_runs(" +#include +#include + +int main(void) { + volatile double base = 1.0; + volatile double infinity = 1.0 / 0.0; + if (pow(base, infinity) != 1.0 || pow(base, -infinity) != 1.0) { + exit(1); + } + if (pow(-base, infinity) != 1.0 || pow(-base, -infinity) != 1.0) { + exit(1); + } + + base = 0.0; + if (pow(base, infinity) != 0.0) { + exit(1); + } + if (pow(base, -infinity) != infinity) { + exit(1); + } + + base = 1.1; + if (pow(-base, infinity) != infinity || pow(base, infinity) != infinity) { + exit(1); + } + if (pow(-base, -infinity) != 0.0 || pow(base, -infinity) != 0.0) { + exit(1); + } + + base = 0.0; + volatile int iexp = 1; + if (pow(-base, -iexp) != -infinity) { + exit(1); + } + if (pow(base, -iexp) != infinity) { + exit(1); + } + exit(0); +}" HAVE_COMPATIBLE_POW) +check_c_source_runs(" +#include +#include + +int main(int argc, char **argv) { + double result; + volatile double base = 3.2e-10; + volatile double exp = 1 - 5e14; + + result = pow(-base, exp); + if (result != -1.0 / 0.0) { + exit(1); + } + exit(0); +}" HAVE_VALID_NEGATIVE_INF_POW) +check_c_source_runs(" +#include +#include + +int main(int argc, char **argv) { + double result; + volatile double base = 3.5; + volatile double exp = 3e100; + + result = pow(-base, exp); + if (result != 1.0 / 0.0) { + exit(1); + } + exit(0); +}" HAVE_VALID_POSITIVE_INF_POW) +check_c_source_runs(" +#include +#include + +int main(void) { + double pi = 3.14159265358979323846; + double result; + volatile double y = 0.0; + volatile double x = 0.0; + + result = atan2(y, -x); + if (fabs(pi - result) > 0.0000001) { + exit(1); + } + + result = atan2(-y, -x); + if (fabs(-pi - result) > 0.0000001) { + exit(1); + } + + result = atan2 (-y, x); + if (result != 0.0 || copysign (1.0, result) > 0) { + exit(1); + } + + result = atan2 (y, x); + if (result != 0.0 || copysign (1.0, result) < 0) { + exit(1); + } + + exit (0); +}" HAVE_COMPATIBLE_ATAN2) +check_c_source_runs(" +#include +#include + +int main(void) { + double d = exp(1.0), e = M_E; + + /* Used memcmp rather than == to test that the doubles are equal to + prevent gcc's optimizer from using its 80 bit internal long + doubles. If you use ==, then on BSD you get a false negative since + exp(1.0) == M_E to 64 bits, but not 80. + */ + + if (memcmp (&d, &e, sizeof (double)) == 0) { + exit(0); + } + exit(1); +}" HAVE_COMPATIBLE_EXP) +check_c_source_runs(" +#include +#include + +int main(void) { + if (FP_ILOGB0 != -2147483648) { + exit(1); + } + + exit(0); +}" HAVE_COMPATIBLE_ILOGB0) +check_c_source_runs(" +#include +#include + +int main(void) { + if (FP_ILOGBNAN != 2147483647) { + exit(1); + } + + exit(0); +}" HAVE_COMPATIBLE_ILOGBNAN) +check_c_source_runs(" +#include +#include + +int main(void) { + volatile int arg = 10000; + if (!isnan(log(-arg))) { + exit(1); + } + exit(0); +}" HAVE_COMPATIBLE_LOG) +check_c_source_runs(" +#include +#include + +int main(void) { + volatile int arg = 10000; + if (!isnan(log10(-arg))) { + exit(1); + } + exit(0); +}" HAVE_COMPATIBLE_LOG10) + +configure_file(${CMAKE_CURRENT_LIST_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h) diff --git a/src/native/netintrinsics/math.c b/src/native/netintrinsics/math.c new file mode 100644 index 00000000000000..0e20c23495c349 --- /dev/null +++ b/src/native/netintrinsics/math.c @@ -0,0 +1,515 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +/*++ + + + +Module Name: + + math.cpp + +Abstract: + + Implementation of math family functions. + + + +--*/ + +#include +#include + +#if HAVE_IEEEFP_H +#include +#endif // HAVE_IEEEFP_H + +#include +#include "config.h" + +#define PAL_NAN_DBL sqrt(-1.0) +#define PAL_POSINF_DBL -log(0.0) +#define PAL_NEGINF_DBL log(0.0) + +#define IS_DBL_NEGZERO(x) (((*((int64_t*)((void*)&x))) & 0xFFFFFFFFFFFFFFFFLL) == 0x8000000000000000LL) + +#define PAL_NAN_FLT sqrtf(-1.0f) +#define PAL_POSINF_FLT -logf(0.0f) +#define PAL_NEGINF_FLT logf(0.0f) + +#define IS_FLT_NEGZERO(x) (((*((INT32*)((void*)&x))) & 0xFFFFFFFF) == 0x80000000) + +double netintrinsics_acos(double x) +{ + double ret; + +#if !HAVE_COMPATIBLE_ACOS + errno = 0; +#endif // HAVE_COMPATIBLE_ACOS + + ret = acos(x); + +#if !HAVE_COMPATIBLE_ACOS + if (errno == EDOM) + { + ret = PAL_NAN_DBL; // NaN + } +#endif // HAVE_COMPATIBLE_ACOS + + return ret; +} + +double netintrinsics_asin(double x) +{ + double ret; + +#if !HAVE_COMPATIBLE_ASIN + errno = 0; +#endif // HAVE_COMPATIBLE_ASIN + + ret = asin(x); + +#if !HAVE_COMPATIBLE_ASIN + if (errno == EDOM) + { + ret = PAL_NAN_DBL; // NaN + } +#endif // HAVE_COMPATIBLE_ASIN + + return ret; +} + +double netintrinsics_atan2(double y, double x) +{ + double ret; + +#if !HAVE_COMPATIBLE_ATAN2 + errno = 0; +#endif // !HAVE_COMPATIBLE_ATAN2 + + ret = atan2(y, x); + +#if !HAVE_COMPATIBLE_ATAN2 + if ((errno == EDOM) && (x == 0.0) && (y == 0.0)) + { + const double sign_x = copysign(1.0, x); + const double sign_y = copysign(1.0, y); + + if (sign_x > 0) + { + ret = copysign(0.0, sign_y); + } + else + { + ret = copysign(atan2(0.0, -1.0), sign_y); + } + } +#endif // !HAVE_COMPATIBLE_ATAN2 + + return ret; +} + +double netintrinsics_exp(double x) +{ + double ret; + +#if !HAVE_COMPATIBLE_EXP + if (x == 1.0) + { + ret = M_E; + } + else + { +#endif // HAVE_COMPATIBLE_EXP + + ret = exp(x); + +#if !HAVE_COMPATIBLE_EXP + } +#endif // HAVE_COMPATIBLE_EXP + + return ret; +} + +int netintrinsics_ilogb(double x) +{ + int ret; +#if !HAVE_COMPATIBLE_ILOGB0 + if (x == 0.0) + { + ret = -2147483648; + } + else +#endif // !HAVE_COMPATIBLE_ILOGB0 + +#if !HAVE_COMPATIBLE_ILOGBNAN + if (isnan(x)) + { + ret = 2147483647; + } + else +#endif // !HAVE_COMPATIBLE_ILOGBNAN + + { + ret = ilogb(x); + } + return ret; +} + +double netintrinsics_log(double x) +{ + double ret; +#if !HAVE_COMPATIBLE_LOG + errno = 0; +#endif // !HAVE_COMPATIBLE_LOG + + ret = log(x); + +#if !HAVE_COMPATIBLE_LOG + if ((errno == EDOM) && (x < 0)) + { + ret = PAL_NAN_DBL; // NaN + } +#endif // !HAVE_COMPATIBLE_LOG + + return ret; +} + +double netintrinsics_log10(double x) +{ + double ret; + +#if !HAVE_COMPATIBLE_LOG10 + errno = 0; +#endif // !HAVE_COMPATIBLE_LOG10 + + ret = log10(x); + +#if !HAVE_COMPATIBLE_LOG10 + if ((errno == EDOM) && (x < 0)) + { + ret = PAL_NAN_DBL; // NaN + } +#endif // !HAVE_COMPATIBLE_LOG10 + + return ret; +} + +double netintrinsics_pow(double x, double y) +{ + double ret; + +#if !HAVE_COMPATIBLE_POW + if ((y == PAL_POSINF_DBL) && !isnan(x)) // +Inf + { + if (x == 1.0) + { + ret = x; + } + else if (x == -1.0) + { + ret = 1.0; + } + else if ((x > -1.0) && (x < 1.0)) + { + ret = 0.0; + } + else + { + ret = PAL_POSINF_DBL; // +Inf + } + } + else if ((y == PAL_NEGINF_DBL) && !isnan(x)) // -Inf + { + if (x == 1.0) + { + ret = x; + } + else if (x == -1.0) + { + ret = 1.0; + } + else if ((x > -1.0) && (x < 1.0)) + { + ret = PAL_POSINF_DBL; // +Inf + } + else + { + ret = 0.0; + } + } + else if (IS_DBL_NEGZERO(x) && (y == -1.0)) + { + ret = PAL_NEGINF_DBL; // -Inf + } + else if ((x == 0.0) && (y < 0.0)) + { + ret = PAL_POSINF_DBL; // +Inf + } + else +#endif // !HAVE_COMPATIBLE_POW + + ret = pow(x, y); + +#if !HAVE_VALID_NEGATIVE_INF_POW + if ((ret == PAL_POSINF_DBL) && (x < 0) && isfinite(x) && (ceil(y / 2) != floor(y / 2))) + { + ret = PAL_NEGINF_DBL; // -Inf + } +#endif // !HAVE_VALID_NEGATIVE_INF_POW + +#if !HAVE_VALID_POSITIVE_INF_POW + /* + * The even/odd test in the if (this one and the one above) used to be ((long long) y % 2 == 0) + * on SPARC (long long) y for large y (>2**63) is always 0x7fffffff7fffffff, which + * is an odd number, so the test ((long long) y % 2 == 0) will always fail for + * large y. Since large double numbers are always even (e.g., the representation of + * 1E20+1 is the same as that of 1E20, the last .+1. is too insignificant to be part + * of the representation), this test will always return the wrong result for large y. + * + * The (ceil(y/2) == floor(y/2)) test is slower, but more robust. + */ + if ((ret == PAL_NEGINF_DBL) && (x < 0) && isfinite(x) && (ceil(y / 2) == floor(y / 2))) + { + ret = PAL_POSINF_DBL; // +Inf + } +#endif // !HAVE_VALID_POSITIVE_INF_POW + + return ret; +} + +float netintrinsics_acosf(float x) +{ + float ret; + +#if !HAVE_COMPATIBLE_ACOS + errno = 0; +#endif // HAVE_COMPATIBLE_ACOS + + ret = acosf(x); + +#if !HAVE_COMPATIBLE_ACOS + if (errno == EDOM) + { + ret = PAL_NAN_FLT; // NaN + } +#endif // HAVE_COMPATIBLE_ACOS + + return ret; +} + +float netintrinsics_asinf(float x) +{ + float ret; + +#if !HAVE_COMPATIBLE_ASIN + errno = 0; +#endif // HAVE_COMPATIBLE_ASIN + + ret = asinf(x); + +#if !HAVE_COMPATIBLE_ASIN + if (errno == EDOM) + { + ret = PAL_NAN_FLT; // NaN + } +#endif // HAVE_COMPATIBLE_ASIN + + return ret; +} + +float netintrinsics_atan2f(float y, float x) +{ + float ret; + +#if !HAVE_COMPATIBLE_ATAN2 + errno = 0; +#endif // !HAVE_COMPATIBLE_ATAN2 + + ret = atan2f(y, x); + +#if !HAVE_COMPATIBLE_ATAN2 + if ((errno == EDOM) && (x == 0.0f) && (y == 0.0f)) + { + const float sign_x = copysign(1.0f, x); + const float sign_y = copysign(1.0f, y); + + if (sign_x > 0) + { + ret = copysign(0.0f, sign_y); + } + else + { + ret = copysign(atan2f(0.0f, -1.0f), sign_y); + } + } +#endif // !HAVE_COMPATIBLE_ATAN2 + + return ret; +} + +float netintrinsics_expf(float x) +{ + float ret; + +#if !HAVE_COMPATIBLE_EXP + if (x == 1.0f) + { + ret = M_E; + } + else + { +#endif // HAVE_COMPATIBLE_EXP + + ret = expf(x); + +#if !HAVE_COMPATIBLE_EXP + } +#endif // HAVE_COMPATIBLE_EXP + + return ret; +} + +int netintrinsics_ilogbf(float x) +{ + int ret; + +#if !HAVE_COMPATIBLE_ILOGB0 + if (x == 0.0f) + { + ret = -2147483648; + } + else +#endif // !HAVE_COMPATIBLE_ILOGB0 + +#if !HAVE_COMPATIBLE_ILOGBNAN + if (isnan(x)) + { + ret = 2147483647; + } + else +#endif // !HAVE_COMPATIBLE_ILOGBNAN + + { + ret = ilogbf(x); + } + + return ret; +} + +float netintrinsics_logf(float x) +{ + float ret; + +#if !HAVE_COMPATIBLE_LOG + errno = 0; +#endif // !HAVE_COMPATIBLE_LOG + + ret = logf(x); + +#if !HAVE_COMPATIBLE_LOG + if ((errno == EDOM) && (x < 0)) + { + ret = PAL_NAN_FLT; // NaN + } +#endif // !HAVE_COMPATIBLE_LOG + + return ret; +} + +float netintrinsics_log10f(float x) +{ + float ret; + +#if !HAVE_COMPATIBLE_LOG10 + errno = 0; +#endif // !HAVE_COMPATIBLE_LOG10 + + ret = log10f(x); + +#if !HAVE_COMPATIBLE_LOG10 + if ((errno == EDOM) && (x < 0)) + { + ret = PAL_NAN_FLT; // NaN + } +#endif // !HAVE_COMPATIBLE_LOG10 + + return ret; +} + +float netintrinsics_powf(float x, float y) +{ + float ret; + +#if !HAVE_COMPATIBLE_POW + if ((y == PAL_POSINF_FLT) && !isnan(x)) // +Inf + { + if (x == 1.0f) + { + ret = x; + } + else if (x == -1.0f) + { + ret = 1.0f; + } + else if ((x > -1.0f) && (x < 1.0f)) + { + ret = 0.0f; + } + else + { + ret = PAL_POSINF_FLT; // +Inf + } + } + else if ((y == PAL_NEGINF_FLT) && !isnan(x)) // -Inf + { + if (x == 1.0f) + { + ret = x; + } + else if (x == -1.0f) + { + ret = 1.0f; + } + else if ((x > -1.0f) && (x < 1.0f)) + { + ret = PAL_POSINF_FLT; // +Inf + } + else + { + ret = 0.0f; + } + } + else if (IS_FLT_NEGZERO(x) && (y == -1.0f)) + { + ret = PAL_NEGINF_FLT; // -Inf + } + else if ((x == 0.0f) && (y < 0.0f)) + { + ret = PAL_POSINF_FLT; // +Inf + } + else +#endif // !HAVE_COMPATIBLE_POW + + ret = powf(x, y); + +#if !HAVE_VALID_NEGATIVE_INF_POW + if ((ret == PAL_POSINF_FLT) && (x < 0) && isfinite(x) && (ceilf(y / 2) != floorf(y / 2))) + { + ret = PAL_NEGINF_FLT; // -Inf + } +#endif // !HAVE_VALID_NEGATIVE_INF_POW + +#if !HAVE_VALID_POSITIVE_INF_POW + /* + * The (ceil(y/2) == floor(y/2)) test is slower, but more robust for platforms where large y + * will return the wrong result for ((long) y % 2 == 0). See PAL_pow(double) above for more details. + */ + if ((ret == PAL_NEGINF_FLT) && (x < 0) && isfinite(x) && (ceilf(y / 2) == floorf(y / 2))) + { + ret = PAL_POSINF_FLT; // +Inf + } +#endif // !HAVE_VALID_POSITIVE_INF_POW + + return ret; +} diff --git a/src/native/netintrinsics/netintrinsics.h b/src/native/netintrinsics/netintrinsics.h new file mode 100644 index 00000000000000..d490ab3f232ed0 --- /dev/null +++ b/src/native/netintrinsics/netintrinsics.h @@ -0,0 +1,45 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +#ifndef NETINTRINSICS_H +#define NETINTRINSICS_H + +#ifdef __cplusplus +extern "C" +{ +#endif +double netintrinsics_acos(double x); + +double netintrinsics_asin(double x); + +double netintrinsics_atan2(double y, double x); + +double netintrinsics_exp(double x); + +int netintrinsics_ilogb(double x); + +double netintrinsics_log(double x); + +double netintrinsics_log10(double x); + +double netintrinsics_pow(double x, double y); + +float netintrinsics_acosf(float x); + +float netintrinsics_asinf(float x); + +float netintrinsics_atan2f(float y, float x); + +float netintrinsics_expf(float x); + +int netintrinsics_ilogbf(float x); + +float netintrinsics_logf(float x); + +float netintrinsics_log10f(float x); + +float netintrinsics_powf(float x, float y); +#ifdef __cplusplus +} +#endif + +#endif // NETINTRINSICS_H \ No newline at end of file From e5b1ae69f077e9612d373cc6c4f8f31e95afd365 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Tue, 6 Feb 2024 18:16:00 +0000 Subject: [PATCH 02/18] Use netintrinsics in mono codegen/interp backends --- src/mono/CMakeLists.txt | 2 ++ src/mono/mono/metadata/CMakeLists.txt | 4 ++-- src/mono/mono/metadata/sysmath.c | 29 ++++++++++++++------------- src/mono/mono/mini/CMakeLists.txt | 8 +++++--- src/mono/mono/mini/interp/interp.c | 29 ++++++++++++++------------- src/mono/mono/mini/intrinsics.c | 5 +++-- 6 files changed, 42 insertions(+), 35 deletions(-) diff --git a/src/mono/CMakeLists.txt b/src/mono/CMakeLists.txt index d5374b3bca6a8a..8d4c3ccfc1a021 100644 --- a/src/mono/CMakeLists.txt +++ b/src/mono/CMakeLists.txt @@ -975,6 +975,8 @@ endif() include_directories("${CLR_SRC_NATIVE_DIR}") +add_subdirectory(${CLR_SRC_NATIVE_DIR}/netintrinsics netintrinsics) + if(NOT DISABLE_LIBS) set(INSTALL_MONO_API 1) endif() diff --git a/src/mono/mono/metadata/CMakeLists.txt b/src/mono/mono/metadata/CMakeLists.txt index a98f21069427ab..9d0e54d4159415 100644 --- a/src/mono/mono/metadata/CMakeLists.txt +++ b/src/mono/mono/metadata/CMakeLists.txt @@ -202,7 +202,7 @@ set(metadata_sources "${metadata_platform_sources};${metadata_common_sources};${ if(HOST_WIN32 AND NOT DISABLE_SHARED_LIBS) add_library(metadata_objects_shared OBJECT ${metadata_sources}) target_compile_definitions(metadata_objects_shared PRIVATE ${metadata_compile_definitions}) - target_link_libraries(metadata_objects_shared PRIVATE monoapi eglib_api utils_objects_shared) + target_link_libraries(metadata_objects_shared PRIVATE monoapi eglib_api utils_objects_shared netintrinsics) # note: metadata_objects is an object library, so this doesn't force linking with sgen, # it just adds the relevant include directories - which we need even with Boehm target_link_libraries(metadata_objects_shared PRIVATE sgen_objects_shared) @@ -214,7 +214,7 @@ endif() add_library(metadata_objects OBJECT ${metadata_sources}) target_compile_definitions(metadata_objects PRIVATE ${metadata_compile_definitions}) -target_link_libraries(metadata_objects PRIVATE monoapi eglib_api utils_objects) +target_link_libraries(metadata_objects PRIVATE monoapi eglib_api utils_objects netintrinsics) # note: metadata_objects is an object library, so this doesn't force linking with sgen, # it just adds the relevant include directories - which we need even with Boehm target_link_libraries(metadata_objects PRIVATE sgen_objects) diff --git a/src/mono/mono/metadata/sysmath.c b/src/mono/mono/metadata/sysmath.c index b7c6006da692cd..4b9b48fba1e419 100644 --- a/src/mono/mono/metadata/sysmath.c +++ b/src/mono/mono/metadata/sysmath.c @@ -25,6 +25,7 @@ #define __USE_ISOC99 #include +#include #include "utils/mono-compiler.h" #include "utils/mono-math.h" @@ -100,7 +101,7 @@ ves_icall_System_Math_Tanh (gdouble x) gdouble ves_icall_System_Math_Acos (gdouble x) { - return acos (x); + return netintrinsics_acos (x); } gdouble @@ -112,7 +113,7 @@ ves_icall_System_Math_Acosh (gdouble x) gdouble ves_icall_System_Math_Asin (gdouble x) { - return asin (x); + return netintrinsics_asin (x); } gdouble @@ -130,7 +131,7 @@ ves_icall_System_Math_Atan (gdouble x) gdouble ves_icall_System_Math_Atan2 (gdouble y, gdouble x) { - return atan2 (y, x); + return netintrinsics_atan2 (y, x); } gdouble @@ -142,25 +143,25 @@ ves_icall_System_Math_Atanh (gdouble x) gdouble ves_icall_System_Math_Exp (gdouble x) { - return exp (x); + return netintrinsics_exp (x); } gdouble ves_icall_System_Math_Log (gdouble x) { - return log (x); + return netintrinsics_log (x); } gdouble ves_icall_System_Math_Log10 (gdouble x) { - return log10 (x); + return netintrinsics_log10 (x); } gdouble ves_icall_System_Math_Pow (gdouble x, gdouble y) { - return pow (x, y); + return netintrinsics_pow (x, y); } gdouble @@ -190,7 +191,7 @@ ves_icall_System_Math_FusedMultiplyAdd (gdouble x, gdouble y, gdouble z) float ves_icall_System_MathF_Acos (float x) { - return acosf (x); + return netintrinsics_acosf (x); } float @@ -202,7 +203,7 @@ ves_icall_System_MathF_Acosh (float x) float ves_icall_System_MathF_Asin (float x) { - return asinf (x); + return netintrinsics_asinf (x); } float @@ -220,7 +221,7 @@ ves_icall_System_MathF_Atan (float x) float ves_icall_System_MathF_Atan2 (float x, float y) { - return atan2f (x, y); + return netintrinsics_atan2f (x, y); } float @@ -256,7 +257,7 @@ ves_icall_System_MathF_Cosh (float x) float ves_icall_System_MathF_Exp (float x) { - return expf (x); + return netintrinsics_expf (x); } float @@ -268,19 +269,19 @@ ves_icall_System_MathF_Floor (float x) float ves_icall_System_MathF_Log (float x) { - return logf (x); + return netintrinsics_logf (x); } float ves_icall_System_MathF_Log10 (float x) { - return log10f (x); + return netintrinsics_log10f (x); } float ves_icall_System_MathF_Pow (float x, float y) { - return powf (x, y); + return netintrinsics_powf (x, y); } float diff --git a/src/mono/mono/mini/CMakeLists.txt b/src/mono/mono/mini/CMakeLists.txt index 5e6ebe9ce49dc4..a7be298c831841 100644 --- a/src/mono/mono/mini/CMakeLists.txt +++ b/src/mono/mono/mini/CMakeLists.txt @@ -337,6 +337,7 @@ endif() if(ENABLE_INTERP_LIB) add_library(mono-ee-interp STATIC "${interp_sources}") target_link_libraries(mono-ee-interp PRIVATE monoapi eglib_api) +target_link_libraries(mono-ee-interp PUBLIC netintrinsics) target_include_directories(mono-ee-interp PRIVATE ${PROJECT_BINARY_DIR}/../.. ${PROJECT_SOURCE_DIR}/../.. ${PROJECT_SOURCE_DIR}/..) @@ -394,17 +395,18 @@ set(monosgen-sources "${mini_sources};${ZLIB_SOURCES}") if(HOST_WIN32 AND NOT DISABLE_SHARED_LIBS) add_library(monosgen-objects_shared OBJECT "${monosgen-sources}") target_compile_definitions(monosgen-objects_shared PRIVATE -DMONO_DLL_EXPORT) - target_link_libraries (monosgen-objects_shared PRIVATE monoapi eglib_api utils_objects_shared sgen_objects_shared metadata_objects_shared) + target_link_libraries (monosgen-objects_shared PRIVATE monoapi eglib_api utils_objects_shared sgen_objects_shared metadata_objects_shared netintrinsics) endif() add_library(monosgen-objects OBJECT "${monosgen-sources}") -target_link_libraries (monosgen-objects PRIVATE monoapi eglib_api utils_objects sgen_objects metadata_objects) +target_link_libraries (monosgen-objects PRIVATE monoapi eglib_api utils_objects sgen_objects metadata_objects netintrinsics) if(NOT HOST_WIN32) target_compile_definitions(monosgen-objects PRIVATE -DMONO_DLL_EXPORT) endif() add_library(monosgen-static STATIC $ $ $ $ $) set_target_properties(monosgen-static PROPERTIES OUTPUT_NAME ${MONO_LIB_NAME}) +target_link_libraries(monosgen-static PUBLIC netintrinsics) if(DISABLE_COMPONENTS OR AOT_COMPONENTS) # add component fallback stubs into static mono library when components have been disabled. @@ -437,7 +439,7 @@ if(NOT DISABLE_SHARED_LIBS) if(HAVE_ICU_SHIM) target_link_libraries(monosgen-shared PRIVATE icu_shim_objects) endif() - target_include_directories (monosgen-shared PRIVATE monoapi) + target_include_directories (monosgen-shared PRIVATE monoapi netintrinsics) if(TARGET_WIN32) # on Windows the import library for the shared mono library will have the same name as the static library, # to avoid a conflict we rename the import library with the .import.lib suffix diff --git a/src/mono/mono/mini/interp/interp.c b/src/mono/mono/mini/interp/interp.c index 23bf79620a73e2..ec2e4b4323b934 100644 --- a/src/mono/mono/mini/interp/interp.c +++ b/src/mono/mono/mini/interp/interp.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -7622,9 +7623,9 @@ MINT_IN_CASE(MINT_BRTRUE_I8_SP) ZEROP_SP(gint64, !=); MINT_IN_BREAK; LOCAL_VAR (ip [1], double) = mathfunc (LOCAL_VAR (ip [2], double), LOCAL_VAR (ip [3], double)); \ ip += 4; - MINT_IN_CASE(MINT_ASIN) MATH_UNOP(asin); MINT_IN_BREAK; + MINT_IN_CASE(MINT_ASIN) MATH_UNOP(netintrinsics_asin); MINT_IN_BREAK; MINT_IN_CASE(MINT_ASINH) MATH_UNOP(asinh); MINT_IN_BREAK; - MINT_IN_CASE(MINT_ACOS) MATH_UNOP(acos); MINT_IN_BREAK; + MINT_IN_CASE(MINT_ACOS) MATH_UNOP(netintrinsics_acos); MINT_IN_BREAK; MINT_IN_CASE(MINT_ACOSH) MATH_UNOP(acosh); MINT_IN_BREAK; MINT_IN_CASE(MINT_ATAN) MATH_UNOP(atan); MINT_IN_BREAK; MINT_IN_CASE(MINT_ATANH) MATH_UNOP(atanh); MINT_IN_BREAK; @@ -7632,11 +7633,11 @@ MINT_IN_CASE(MINT_BRTRUE_I8_SP) ZEROP_SP(gint64, !=); MINT_IN_BREAK; MINT_IN_CASE(MINT_COS) MATH_UNOP(cos); MINT_IN_BREAK; MINT_IN_CASE(MINT_CBRT) MATH_UNOP(cbrt); MINT_IN_BREAK; MINT_IN_CASE(MINT_COSH) MATH_UNOP(cosh); MINT_IN_BREAK; - MINT_IN_CASE(MINT_EXP) MATH_UNOP(exp); MINT_IN_BREAK; + MINT_IN_CASE(MINT_EXP) MATH_UNOP(netintrinsics_exp); MINT_IN_BREAK; MINT_IN_CASE(MINT_FLOOR) MATH_UNOP(floor); MINT_IN_BREAK; - MINT_IN_CASE(MINT_LOG) MATH_UNOP(log); MINT_IN_BREAK; + MINT_IN_CASE(MINT_LOG) MATH_UNOP(netintrinsics_log); MINT_IN_BREAK; MINT_IN_CASE(MINT_LOG2) MATH_UNOP(log2); MINT_IN_BREAK; - MINT_IN_CASE(MINT_LOG10) MATH_UNOP(log10); MINT_IN_BREAK; + MINT_IN_CASE(MINT_LOG10) MATH_UNOP(netintrinsics_log10); MINT_IN_BREAK; MINT_IN_CASE(MINT_SIN) MATH_UNOP(sin); MINT_IN_BREAK; MINT_IN_CASE(MINT_SQRT) MATH_UNOP(sqrt); MINT_IN_BREAK; MINT_IN_CASE(MINT_SINH) MATH_UNOP(sinh); MINT_IN_BREAK; @@ -7644,8 +7645,8 @@ MINT_IN_CASE(MINT_BRTRUE_I8_SP) ZEROP_SP(gint64, !=); MINT_IN_BREAK; MINT_IN_CASE(MINT_TANH) MATH_UNOP(tanh); MINT_IN_BREAK; MINT_IN_CASE(MINT_ABS) MATH_UNOP(fabs); MINT_IN_BREAK; - MINT_IN_CASE(MINT_ATAN2) MATH_BINOP(atan2); MINT_IN_BREAK; - MINT_IN_CASE(MINT_POW) MATH_BINOP(pow); MINT_IN_BREAK; + MINT_IN_CASE(MINT_ATAN2) MATH_BINOP(netintrinsics_atan2); MINT_IN_BREAK; + MINT_IN_CASE(MINT_POW) MATH_BINOP(netintrinsics_pow); MINT_IN_BREAK; MINT_IN_CASE(MINT_MIN) MATH_BINOP(min_d); MINT_IN_BREAK; MINT_IN_CASE(MINT_MAX) MATH_BINOP(max_d); MINT_IN_BREAK; MINT_IN_CASE(MINT_FMA) @@ -7664,9 +7665,9 @@ MINT_IN_CASE(MINT_BRTRUE_I8_SP) ZEROP_SP(gint64, !=); MINT_IN_BREAK; #define MATH_BINOPF(mathfunc) \ LOCAL_VAR (ip [1], float) = mathfunc (LOCAL_VAR (ip [2], float), LOCAL_VAR (ip [3], float)); \ ip += 4; - MINT_IN_CASE(MINT_ASINF) MATH_UNOPF(asinf); MINT_IN_BREAK; + MINT_IN_CASE(MINT_ASINF) MATH_UNOPF(netintrinsics_asinf); MINT_IN_BREAK; MINT_IN_CASE(MINT_ASINHF) MATH_UNOPF(asinhf); MINT_IN_BREAK; - MINT_IN_CASE(MINT_ACOSF) MATH_UNOPF(acosf); MINT_IN_BREAK; + MINT_IN_CASE(MINT_ACOSF) MATH_UNOPF(netintrinsics_acosf); MINT_IN_BREAK; MINT_IN_CASE(MINT_ACOSHF) MATH_UNOPF(acoshf); MINT_IN_BREAK; MINT_IN_CASE(MINT_ATANF) MATH_UNOPF(atanf); MINT_IN_BREAK; MINT_IN_CASE(MINT_ATANHF) MATH_UNOPF(atanhf); MINT_IN_BREAK; @@ -7674,11 +7675,11 @@ MINT_IN_CASE(MINT_BRTRUE_I8_SP) ZEROP_SP(gint64, !=); MINT_IN_BREAK; MINT_IN_CASE(MINT_COSF) MATH_UNOPF(cosf); MINT_IN_BREAK; MINT_IN_CASE(MINT_CBRTF) MATH_UNOPF(cbrtf); MINT_IN_BREAK; MINT_IN_CASE(MINT_COSHF) MATH_UNOPF(coshf); MINT_IN_BREAK; - MINT_IN_CASE(MINT_EXPF) MATH_UNOPF(expf); MINT_IN_BREAK; + MINT_IN_CASE(MINT_EXPF) MATH_UNOPF(netintrinsics_expf); MINT_IN_BREAK; MINT_IN_CASE(MINT_FLOORF) MATH_UNOPF(floorf); MINT_IN_BREAK; - MINT_IN_CASE(MINT_LOGF) MATH_UNOPF(logf); MINT_IN_BREAK; + MINT_IN_CASE(MINT_LOGF) MATH_UNOPF(netintrinsics_logf); MINT_IN_BREAK; MINT_IN_CASE(MINT_LOG2F) MATH_UNOPF(log2f); MINT_IN_BREAK; - MINT_IN_CASE(MINT_LOG10F) MATH_UNOPF(log10f); MINT_IN_BREAK; + MINT_IN_CASE(MINT_LOG10F) MATH_UNOPF(netintrinsics_log10f); MINT_IN_BREAK; MINT_IN_CASE(MINT_SINF) MATH_UNOPF(sinf); MINT_IN_BREAK; MINT_IN_CASE(MINT_SQRTF) MATH_UNOPF(sqrtf); MINT_IN_BREAK; MINT_IN_CASE(MINT_SINHF) MATH_UNOPF(sinhf); MINT_IN_BREAK; @@ -7686,8 +7687,8 @@ MINT_IN_CASE(MINT_BRTRUE_I8_SP) ZEROP_SP(gint64, !=); MINT_IN_BREAK; MINT_IN_CASE(MINT_TANHF) MATH_UNOPF(tanhf); MINT_IN_BREAK; MINT_IN_CASE(MINT_ABSF) MATH_UNOPF(fabsf); MINT_IN_BREAK; - MINT_IN_CASE(MINT_ATAN2F) MATH_BINOPF(atan2f); MINT_IN_BREAK; - MINT_IN_CASE(MINT_POWF) MATH_BINOPF(powf); MINT_IN_BREAK; + MINT_IN_CASE(MINT_ATAN2F) MATH_BINOPF(netintrinsics_atan2f); MINT_IN_BREAK; + MINT_IN_CASE(MINT_POWF) MATH_BINOPF(netintrinsics_powf); MINT_IN_BREAK; MINT_IN_CASE(MINT_MINF) MATH_BINOPF(min_f); MINT_IN_BREAK; MINT_IN_CASE(MINT_MAXF) MATH_BINOPF(max_f); MINT_IN_BREAK; MINT_IN_CASE(MINT_FMAF) diff --git a/src/mono/mono/mini/intrinsics.c b/src/mono/mono/mini/intrinsics.c index 1c1dede53bc5e8..d58e8213268957 100644 --- a/src/mono/mono/mini/intrinsics.c +++ b/src/mono/mono/mini/intrinsics.c @@ -7,6 +7,7 @@ #include #include #include +#include #ifndef DISABLE_JIT @@ -1864,13 +1865,13 @@ mini_emit_inst_for_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSign result = fabs (source); break; case OP_ACOS: - result = acos (source); + result = netintrinsics_acos (source); break; case OP_ACOSH: result = acosh (source); break; case OP_ASIN: - result = asin (source); + result = netintrinsics_asin (source); break; case OP_ASINH: result= asinh (source); From 3fc672d7a482c6d93246f2e3c745d39b11b9aed8 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Tue, 6 Feb 2024 18:30:55 +0000 Subject: [PATCH 03/18] Update NativeAOT to use the netintrinsics APIs as well --- .../nativeaot/Runtime/Full/CMakeLists.txt | 3 ++ .../src/System/Runtime/RuntimeImports.cs | 28 +++++++++---------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/coreclr/nativeaot/Runtime/Full/CMakeLists.txt b/src/coreclr/nativeaot/Runtime/Full/CMakeLists.txt index e665a6c88ee10b..49f466c3226d38 100644 --- a/src/coreclr/nativeaot/Runtime/Full/CMakeLists.txt +++ b/src/coreclr/nativeaot/Runtime/Full/CMakeLists.txt @@ -28,9 +28,11 @@ endif (CLR_CMAKE_TARGET_WIN32) add_library(Runtime.WorkstationGC STATIC ${COMMON_RUNTIME_SOURCES} ${FULL_RUNTIME_SOURCES} ${RUNTIME_SOURCES_ARCH_ASM} ${RUNTIME_ARCH_ASM_OBJECTS}) add_dependencies(Runtime.WorkstationGC aot_eventing_headers) +target_link_libraries(Runtime.WorkstationGC PUBLIC netintrinsics) add_library(Runtime.ServerGC STATIC ${COMMON_RUNTIME_SOURCES} ${FULL_RUNTIME_SOURCES} ${RUNTIME_SOURCES_ARCH_ASM} ${SERVER_GC_SOURCES} ${RUNTIME_ARCH_ASM_OBJECTS}) add_dependencies(Runtime.ServerGC aot_eventing_headers) +target_link_libraries(Runtime.ServerGC PUBLIC netintrinsics) add_library(standalonegc-disabled STATIC ${STANDALONEGC_DISABLED_SOURCES}) add_dependencies(standalonegc-disabled aot_eventing_headers) @@ -58,6 +60,7 @@ if (CLR_CMAKE_TARGET_WIN32) add_dependencies(standalonegc-enabled.GuardCF aot_eventing_headers) add_dependencies(standalonegc-enabled.GuardCF aot_etw_headers) add_library(Runtime.ServerGC.GuardCF STATIC ${COMMON_RUNTIME_SOURCES} ${FULL_RUNTIME_SOURCES} ${RUNTIME_SOURCES_ARCH_ASM} ${SERVER_GC_SOURCES} ${RUNTIME_ARCH_ASM_OBJECTS}) + target_link_libraries(Runtime.ServerGC.GuardCF PUBLIC netintrinsics) target_compile_definitions(Runtime.ServerGC.GuardCF PRIVATE -DFEATURE_SVR_GC) set_target_properties(Runtime.ServerGC.GuardCF PROPERTIES CLR_CONTROL_FLOW_GUARD ON) diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/RuntimeImports.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/RuntimeImports.cs index 5f1211b5059fc3..4c4171e05433a5 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/RuntimeImports.cs +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/RuntimeImports.cs @@ -847,12 +847,12 @@ internal static partial void NativeRuntimeEventSource_LogWaitHandleWaitStart( [Intrinsic] [MethodImplAttribute(MethodImplOptions.InternalCall)] - [RuntimeImport(RuntimeLibrary, "acos")] + [RuntimeImport(RuntimeLibrary, "netintrinsics_acos")] internal static extern double acos(double x); [Intrinsic] [MethodImplAttribute(MethodImplOptions.InternalCall)] - [RuntimeImport(RuntimeLibrary, "acosf")] + [RuntimeImport(RuntimeLibrary, "netintrinsics_acosf")] internal static extern float acosf(float x); [Intrinsic] @@ -867,12 +867,12 @@ internal static partial void NativeRuntimeEventSource_LogWaitHandleWaitStart( [Intrinsic] [MethodImplAttribute(MethodImplOptions.InternalCall)] - [RuntimeImport(RuntimeLibrary, "asin")] + [RuntimeImport(RuntimeLibrary, "netintrinsics_asin")] internal static extern double asin(double x); [Intrinsic] [MethodImplAttribute(MethodImplOptions.InternalCall)] - [RuntimeImport(RuntimeLibrary, "asinf")] + [RuntimeImport(RuntimeLibrary, "netintrinsics_asinf")] internal static extern float asinf(float x); [Intrinsic] @@ -897,12 +897,12 @@ internal static partial void NativeRuntimeEventSource_LogWaitHandleWaitStart( [Intrinsic] [MethodImplAttribute(MethodImplOptions.InternalCall)] - [RuntimeImport(RuntimeLibrary, "atan2")] + [RuntimeImport(RuntimeLibrary, "netintrinsics_atan2")] internal static extern double atan2(double y, double x); [Intrinsic] [MethodImplAttribute(MethodImplOptions.InternalCall)] - [RuntimeImport(RuntimeLibrary, "atan2f")] + [RuntimeImport(RuntimeLibrary, "netintrinsics_atan2f")] internal static extern float atan2f(float y, float x); [Intrinsic] @@ -957,12 +957,12 @@ internal static partial void NativeRuntimeEventSource_LogWaitHandleWaitStart( [Intrinsic] [MethodImplAttribute(MethodImplOptions.InternalCall)] - [RuntimeImport(RuntimeLibrary, "exp")] + [RuntimeImport(RuntimeLibrary, "netintrinsics_exp")] internal static extern double exp(double x); [Intrinsic] [MethodImplAttribute(MethodImplOptions.InternalCall)] - [RuntimeImport(RuntimeLibrary, "expf")] + [RuntimeImport(RuntimeLibrary, "netintrinsics_expf")] internal static extern float expf(float x); [Intrinsic] @@ -977,12 +977,12 @@ internal static partial void NativeRuntimeEventSource_LogWaitHandleWaitStart( [Intrinsic] [MethodImplAttribute(MethodImplOptions.InternalCall)] - [RuntimeImport(RuntimeLibrary, "log")] + [RuntimeImport(RuntimeLibrary, "netintrinsics_log")] internal static extern double log(double x); [Intrinsic] [MethodImplAttribute(MethodImplOptions.InternalCall)] - [RuntimeImport(RuntimeLibrary, "logf")] + [RuntimeImport(RuntimeLibrary, "netintrinsics_logf")] internal static extern float logf(float x); [Intrinsic] @@ -997,22 +997,22 @@ internal static partial void NativeRuntimeEventSource_LogWaitHandleWaitStart( [Intrinsic] [MethodImplAttribute(MethodImplOptions.InternalCall)] - [RuntimeImport(RuntimeLibrary, "log10")] + [RuntimeImport(RuntimeLibrary, "netintrinsics_log10")] internal static extern double log10(double x); [Intrinsic] [MethodImplAttribute(MethodImplOptions.InternalCall)] - [RuntimeImport(RuntimeLibrary, "log10f")] + [RuntimeImport(RuntimeLibrary, "netintrinsics_log10f")] internal static extern float log10f(float x); [Intrinsic] [MethodImplAttribute(MethodImplOptions.InternalCall)] - [RuntimeImport(RuntimeLibrary, "pow")] + [RuntimeImport(RuntimeLibrary, "netintrinsics_pow")] internal static extern double pow(double x, double y); [Intrinsic] [MethodImplAttribute(MethodImplOptions.InternalCall)] - [RuntimeImport(RuntimeLibrary, "powf")] + [RuntimeImport(RuntimeLibrary, "netintrinsics_powf")] internal static extern float powf(float x, float y); [Intrinsic] From c3afdce1617065b66aa163defacda299fbb08a15 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Tue, 6 Feb 2024 18:56:32 +0000 Subject: [PATCH 04/18] Remove unused defines --- src/coreclr/pal/src/cruntime/math.cpp | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/src/coreclr/pal/src/cruntime/math.cpp b/src/coreclr/pal/src/cruntime/math.cpp index 94cf864c9235b0..802a647f5a275a 100644 --- a/src/coreclr/pal/src/cruntime/math.cpp +++ b/src/coreclr/pal/src/cruntime/math.cpp @@ -22,26 +22,6 @@ Module Name: #include -#if HAVE_IEEEFP_H -#include -#endif // HAVE_IEEEFP_H - -#include - -#define PAL_NAN_DBL sqrt(-1.0) -#define PAL_POSINF_DBL -log(0.0) -#define PAL_NEGINF_DBL log(0.0) - -#define IS_DBL_NEGZERO(x) (((*((INT64*)((void*)&x))) & I64(0xFFFFFFFFFFFFFFFF)) == I64(0x8000000000000000)) - -#define PAL_NAN_FLT sqrtf(-1.0f) -#define PAL_POSINF_FLT -logf(0.0f) -#define PAL_NEGINF_FLT logf(0.0f) - -#define IS_FLT_NEGZERO(x) (((*((INT32*)((void*)&x))) & 0xFFFFFFFF) == 0x80000000) - -SET_DEFAULT_DEBUG_CHANNEL(CRT); - /*++ Function: _finite From ab98412a42bf6ad742d5f90ff4f5c0b5805ff04a Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Tue, 6 Feb 2024 19:03:08 +0000 Subject: [PATCH 05/18] Remove now-duplicate configure steps --- src/coreclr/pal/src/config.h.in | 11 -- src/coreclr/pal/src/configure.cmake | 208 ---------------------------- 2 files changed, 219 deletions(-) diff --git a/src/coreclr/pal/src/config.h.in b/src/coreclr/pal/src/config.h.in index b5ddd025f3eb1a..aba4249541b434 100644 --- a/src/coreclr/pal/src/config.h.in +++ b/src/coreclr/pal/src/config.h.in @@ -119,17 +119,6 @@ #cmakedefine01 SEM_INIT_MODIFIES_ERRNO #cmakedefine01 HAVE_PROCFS_CTL #cmakedefine01 HAVE_PROCFS_STAT -#cmakedefine01 HAVE_COMPATIBLE_ACOS -#cmakedefine01 HAVE_COMPATIBLE_ASIN -#cmakedefine01 HAVE_COMPATIBLE_POW -#cmakedefine01 HAVE_VALID_NEGATIVE_INF_POW -#cmakedefine01 HAVE_VALID_POSITIVE_INF_POW -#cmakedefine01 HAVE_COMPATIBLE_ATAN2 -#cmakedefine01 HAVE_COMPATIBLE_EXP -#cmakedefine01 HAVE_COMPATIBLE_ILOGB0 -#cmakedefine01 HAVE_COMPATIBLE_ILOGBNAN -#cmakedefine01 HAVE_COMPATIBLE_LOG -#cmakedefine01 HAVE_COMPATIBLE_LOG10 #cmakedefine01 UNGETC_NOT_RETURN_EOF #cmakedefine01 HAS_POSIX_SEMAPHORES #cmakedefine01 FILE_OPS_CHECK_FERROR_OF_PREVIOUS_CALL diff --git a/src/coreclr/pal/src/configure.cmake b/src/coreclr/pal/src/configure.cmake index b8cdb3a4df4131..ed730378074c3c 100644 --- a/src/coreclr/pal/src/configure.cmake +++ b/src/coreclr/pal/src/configure.cmake @@ -644,214 +644,6 @@ int main(void) { exit(0); }" HAVE_PROCFS_STAT) set(CMAKE_REQUIRED_LIBRARIES) -set(CMAKE_REQUIRED_LIBRARIES m) -check_cxx_source_runs(" -#include -#include - -int main(void) { - volatile double x = 10; - if (!isnan(acos(x))) { - exit(1); - } - exit(0); -}" HAVE_COMPATIBLE_ACOS) -set(CMAKE_REQUIRED_LIBRARIES) -set(CMAKE_REQUIRED_LIBRARIES m) -check_cxx_source_runs(" -#include -#include - -int main(void) { - volatile double arg = 10; - if (!isnan(asin(arg))) { - exit(1); - } - exit(0); -}" HAVE_COMPATIBLE_ASIN) -set(CMAKE_REQUIRED_LIBRARIES) -set(CMAKE_REQUIRED_LIBRARIES m) -check_cxx_source_runs(" -#include -#include - -int main(void) { - volatile double base = 1.0; - volatile double infinity = 1.0 / 0.0; - if (pow(base, infinity) != 1.0 || pow(base, -infinity) != 1.0) { - exit(1); - } - if (pow(-base, infinity) != 1.0 || pow(-base, -infinity) != 1.0) { - exit(1); - } - - base = 0.0; - if (pow(base, infinity) != 0.0) { - exit(1); - } - if (pow(base, -infinity) != infinity) { - exit(1); - } - - base = 1.1; - if (pow(-base, infinity) != infinity || pow(base, infinity) != infinity) { - exit(1); - } - if (pow(-base, -infinity) != 0.0 || pow(base, -infinity) != 0.0) { - exit(1); - } - - base = 0.0; - volatile int iexp = 1; - if (pow(-base, -iexp) != -infinity) { - exit(1); - } - if (pow(base, -iexp) != infinity) { - exit(1); - } - exit(0); -}" HAVE_COMPATIBLE_POW) -set(CMAKE_REQUIRED_LIBRARIES) -set(CMAKE_REQUIRED_LIBRARIES m) -check_cxx_source_runs(" -#include -#include - -int main(int argc, char **argv) { - double result; - volatile double base = 3.2e-10; - volatile double exp = 1 - 5e14; - - result = pow(-base, exp); - if (result != -1.0 / 0.0) { - exit(1); - } - exit(0); -}" HAVE_VALID_NEGATIVE_INF_POW) -set(CMAKE_REQUIRED_LIBRARIES) -set(CMAKE_REQUIRED_LIBRARIES m) -check_cxx_source_runs(" -#include -#include - -int main(int argc, char **argv) { - double result; - volatile double base = 3.5; - volatile double exp = 3e100; - - result = pow(-base, exp); - if (result != 1.0 / 0.0) { - exit(1); - } - exit(0); -}" HAVE_VALID_POSITIVE_INF_POW) -set(CMAKE_REQUIRED_LIBRARIES) -set(CMAKE_REQUIRED_LIBRARIES m) -check_cxx_source_runs(" -#include -#include - -int main(void) { - double pi = 3.14159265358979323846; - double result; - volatile double y = 0.0; - volatile double x = 0.0; - - result = atan2(y, -x); - if (fabs(pi - result) > 0.0000001) { - exit(1); - } - - result = atan2(-y, -x); - if (fabs(-pi - result) > 0.0000001) { - exit(1); - } - - result = atan2 (-y, x); - if (result != 0.0 || copysign (1.0, result) > 0) { - exit(1); - } - - result = atan2 (y, x); - if (result != 0.0 || copysign (1.0, result) < 0) { - exit(1); - } - - exit (0); -}" HAVE_COMPATIBLE_ATAN2) -set(CMAKE_REQUIRED_LIBRARIES) -set(CMAKE_REQUIRED_LIBRARIES m) -check_cxx_source_runs(" -#include -#include - -int main(void) { - double d = exp(1.0), e = M_E; - - /* Used memcmp rather than == to test that the doubles are equal to - prevent gcc's optimizer from using its 80 bit internal long - doubles. If you use ==, then on BSD you get a false negative since - exp(1.0) == M_E to 64 bits, but not 80. - */ - - if (memcmp (&d, &e, sizeof (double)) == 0) { - exit(0); - } - exit(1); -}" HAVE_COMPATIBLE_EXP) -set(CMAKE_REQUIRED_LIBRARIES) -set(CMAKE_REQUIRED_LIBRARIES m) -check_cxx_source_runs(" -#include -#include - -int main(void) { - if (FP_ILOGB0 != -2147483648) { - exit(1); - } - - exit(0); -}" HAVE_COMPATIBLE_ILOGB0) -set(CMAKE_REQUIRED_LIBRARIES) -set(CMAKE_REQUIRED_LIBRARIES m) -check_cxx_source_runs(" -#include -#include - -int main(void) { - if (FP_ILOGBNAN != 2147483647) { - exit(1); - } - - exit(0); -}" HAVE_COMPATIBLE_ILOGBNAN) -set(CMAKE_REQUIRED_LIBRARIES) -set(CMAKE_REQUIRED_LIBRARIES m) -check_cxx_source_runs(" -#include -#include - -int main(void) { - volatile int arg = 10000; - if (!isnan(log(-arg))) { - exit(1); - } - exit(0); -}" HAVE_COMPATIBLE_LOG) -set(CMAKE_REQUIRED_LIBRARIES) -set(CMAKE_REQUIRED_LIBRARIES m) -check_cxx_source_runs(" -#include -#include - -int main(void) { - volatile int arg = 10000; - if (!isnan(log10(-arg))) { - exit(1); - } - exit(0); -}" HAVE_COMPATIBLE_LOG10) -set(CMAKE_REQUIRED_LIBRARIES) check_cxx_source_runs(" #include #include From a50183875a2e68e65fc042880712c15789503f4a Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Tue, 6 Feb 2024 19:31:47 +0000 Subject: [PATCH 06/18] Add back default debug channel --- src/coreclr/pal/src/cruntime/math.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/coreclr/pal/src/cruntime/math.cpp b/src/coreclr/pal/src/cruntime/math.cpp index 802a647f5a275a..c8f24d8079c1ab 100644 --- a/src/coreclr/pal/src/cruntime/math.cpp +++ b/src/coreclr/pal/src/cruntime/math.cpp @@ -22,6 +22,8 @@ Module Name: #include +SET_DEFAULT_DEBUG_CHANNEL(CRT); + /*++ Function: _finite From 9d45460d7f9ff1f38c2fd80c266fbbbf369ea873 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Tue, 6 Feb 2024 20:34:21 +0000 Subject: [PATCH 07/18] Fix macro name --- src/native/netintrinsics/configure.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/native/netintrinsics/configure.cmake b/src/native/netintrinsics/configure.cmake index 6eb29ba7b174f9..528aa3e9959af7 100644 --- a/src/native/netintrinsics/configure.cmake +++ b/src/native/netintrinsics/configure.cmake @@ -7,7 +7,7 @@ elseif(CLR_CMAKE_TARGET_SUNOS) set(CMAKE_REQUIRED_INCLUDES /opt/local/include) endif() -check_include_files(ieeefp.h HAVE_IEEEFP_H) +check_include_file(ieeefp.h HAVE_IEEEFP_H) set(CMAKE_REQUIRED_LIBRARIES m) check_c_source_runs(" From f2b0cadded48c10ecbd7f5bd18d0beeef99eb020 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Tue, 6 Feb 2024 23:08:44 +0000 Subject: [PATCH 08/18] Add sincos to PAL headers on Apple platforms --- src/coreclr/pal/inc/pal.h | 6 ++++++ src/coreclr/pal/tests/palsuite/common/palsuite.h | 1 + 2 files changed, 7 insertions(+) diff --git a/src/coreclr/pal/inc/pal.h b/src/coreclr/pal/inc/pal.h index 2e459981242a8b..0bdb0ff6abab07 100644 --- a/src/coreclr/pal/inc/pal.h +++ b/src/coreclr/pal/inc/pal.h @@ -4219,6 +4219,9 @@ PALIMPORT double __cdecl modf(double, double*); PALIMPORT double __cdecl pow(double, double); PALIMPORT double __cdecl sin(double); PALIMPORT void __cdecl sincos(double, double*, double*); +#ifdef __APPLE__ +PALIMPORT void __cdecl __sincos(double, double*, double*); +#endif PALIMPORT double __cdecl sinh(double); PALIMPORT double __cdecl sqrt(double); PALIMPORT double __cdecl tan(double); @@ -4252,6 +4255,9 @@ PALIMPORT float __cdecl modff(float, float*); PALIMPORT float __cdecl powf(float, float); PALIMPORT float __cdecl sinf(float); PALIMPORT void __cdecl sincosf(float, float*, float*); +#ifdef __APPLE__ +PALIMPORT void __cdecl __sincosf(float, float*, float*); +#endif PALIMPORT float __cdecl sinhf(float); PALIMPORT float __cdecl sqrtf(float); PALIMPORT float __cdecl tanf(float); diff --git a/src/coreclr/pal/tests/palsuite/common/palsuite.h b/src/coreclr/pal/tests/palsuite/common/palsuite.h index 640a458232c69f..c275b3812a256c 100644 --- a/src/coreclr/pal/tests/palsuite/common/palsuite.h +++ b/src/coreclr/pal/tests/palsuite/common/palsuite.h @@ -1,3 +1,4 @@ +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /*============================================================================ From cf4b2d3319117f2315cd733b69ebbcc3980cd532 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Tue, 6 Feb 2024 23:41:03 +0000 Subject: [PATCH 09/18] Move ilogb intrinsic handling into RyuJIT (as we still need this one special handling) and remove the netintrinsics library --- src/coreclr/CMakeLists.txt | 5 - .../classlibnative/float/CMakeLists.txt | 1 - .../classlibnative/float/floatdouble.cpp | 15 +- .../classlibnative/float/floatsingle.cpp | 15 +- src/coreclr/jit/CMakeLists.txt | 1 - src/coreclr/jit/jitpch.h | 1 - src/coreclr/jit/static/CMakeLists.txt | 1 - src/coreclr/jit/utils.cpp | 26 + src/coreclr/jit/utils.h | 4 + src/coreclr/jit/valuenum.cpp | 32 +- .../nativeaot/Runtime/Full/CMakeLists.txt | 3 - .../src/System/Runtime/RuntimeImports.cs | 28 +- src/mono/CMakeLists.txt | 2 - src/mono/mono/metadata/CMakeLists.txt | 4 +- src/mono/mono/metadata/sysmath.c | 29 +- src/mono/mono/mini/CMakeLists.txt | 10 +- src/mono/mono/mini/interp/interp.c | 29 +- src/mono/mono/mini/intrinsics.c | 5 +- .../corehost/apphost/static/CMakeLists.txt | 4 - src/native/netintrinsics/CMakeLists.txt | 8 - src/native/netintrinsics/config.h.in | 17 - src/native/netintrinsics/configure.cmake | 200 ------- src/native/netintrinsics/math.c | 515 ------------------ src/native/netintrinsics/netintrinsics.h | 45 -- 24 files changed, 111 insertions(+), 889 deletions(-) delete mode 100644 src/native/netintrinsics/CMakeLists.txt delete mode 100644 src/native/netintrinsics/config.h.in delete mode 100644 src/native/netintrinsics/configure.cmake delete mode 100644 src/native/netintrinsics/math.c delete mode 100644 src/native/netintrinsics/netintrinsics.h diff --git a/src/coreclr/CMakeLists.txt b/src/coreclr/CMakeLists.txt index 1b7f01bc8e7648..1c314d9bf624e0 100644 --- a/src/coreclr/CMakeLists.txt +++ b/src/coreclr/CMakeLists.txt @@ -79,11 +79,6 @@ if(NOT CLR_CROSS_COMPONENTS_BUILD) add_subdirectory(${CLR_SRC_NATIVE_DIR}/libs libs-native) endif(NOT CLR_CROSS_COMPONENTS_BUILD) -#------------------------------- -# Include shared native libraries -#------------------------------- -add_subdirectory(${CLR_SRC_NATIVE_DIR}/netintrinsics netintrinsics) - #----------------------------------------- # Add Projects # - project which require platform header not clr's diff --git a/src/coreclr/classlibnative/float/CMakeLists.txt b/src/coreclr/classlibnative/float/CMakeLists.txt index fa31a13c420273..1dbe160248f26e 100644 --- a/src/coreclr/classlibnative/float/CMakeLists.txt +++ b/src/coreclr/classlibnative/float/CMakeLists.txt @@ -6,5 +6,4 @@ set(FLOAT_SOURCES ) add_library_clr(comfloat_wks OBJECT ${FLOAT_SOURCES}) -target_link_libraries(comfloat_wks PRIVATE netintrinsics) add_dependencies(comfloat_wks eventing_headers) diff --git a/src/coreclr/classlibnative/float/floatdouble.cpp b/src/coreclr/classlibnative/float/floatdouble.cpp index 282f85e5b16a12..7b0b3d13ab1790 100644 --- a/src/coreclr/classlibnative/float/floatdouble.cpp +++ b/src/coreclr/classlibnative/float/floatdouble.cpp @@ -5,7 +5,6 @@ // #include -#include "netintrinsics.h" #include "floatdouble.h" @@ -49,7 +48,7 @@ FCIMPL1_V(double, COMDouble::Acos, double x) FCALL_CONTRACT; - return netintrinsics_acos(x); + return acos(x); FCIMPLEND /*=====================================Acosh==================================== @@ -67,7 +66,7 @@ FCIMPLEND FCIMPL1_V(double, COMDouble::Asin, double x) FCALL_CONTRACT; - return netintrinsics_asin(x); + return asin(x); FCIMPLEND /*=====================================Asinh==================================== @@ -103,7 +102,7 @@ FCIMPLEND FCIMPL2_VV(double, COMDouble::Atan2, double y, double x) FCALL_CONTRACT; - return netintrinsics_atan2(y, x); + return atan2(y, x); FCIMPLEND /*====================================Cbrt====================================== @@ -159,7 +158,7 @@ FCIMPLEND FCIMPL1_V(double, COMDouble::Exp, double x) FCALL_CONTRACT; - return netintrinsics_exp(x); + return exp(x); FCIMPLEND #if defined(_MSC_VER) && defined(TARGET_X86) @@ -206,7 +205,7 @@ FCIMPLEND FCIMPL1_V(double, COMDouble::Log, double x) FCALL_CONTRACT; - return netintrinsics_log(x); + return log(x); FCIMPLEND /*=====================================Log2===================================== @@ -224,7 +223,7 @@ FCIMPLEND FCIMPL1_V(double, COMDouble::Log10, double x) FCALL_CONTRACT; - return netintrinsics_log10(x); + return log10(x); FCIMPLEND /*=====================================ModF===================================== @@ -242,7 +241,7 @@ FCIMPLEND FCIMPL2_VV(double, COMDouble::Pow, double x, double y) FCALL_CONTRACT; - return netintrinsics_pow(x, y); + return pow(x, y); FCIMPLEND /*=====================================Sin====================================== diff --git a/src/coreclr/classlibnative/float/floatsingle.cpp b/src/coreclr/classlibnative/float/floatsingle.cpp index f74cf0f5550bb8..8b790599a4cada 100644 --- a/src/coreclr/classlibnative/float/floatsingle.cpp +++ b/src/coreclr/classlibnative/float/floatsingle.cpp @@ -5,7 +5,6 @@ // #include -#include "netintrinsics.h" #include "floatsingle.h" @@ -35,7 +34,7 @@ FCIMPL1_V(float, COMSingle::Acos, float x) FCALL_CONTRACT; - return netintrinsics_acosf(x); + return acosf(x); FCIMPLEND /*=====================================Acosh==================================== @@ -53,7 +52,7 @@ FCIMPLEND FCIMPL1_V(float, COMSingle::Asin, float x) FCALL_CONTRACT; - return netintrinsics_asinf(x); + return asinf(x); FCIMPLEND /*=====================================Asinh==================================== @@ -89,7 +88,7 @@ FCIMPLEND FCIMPL2_VV(float, COMSingle::Atan2, float y, float x) FCALL_CONTRACT; - return netintrinsics_atan2f(y, x); + return atan2f(y, x); FCIMPLEND /*====================================Cbrt====================================== @@ -145,7 +144,7 @@ FCIMPLEND FCIMPL1_V(float, COMSingle::Exp, float x) FCALL_CONTRACT; - return netintrinsics_expf(x); + return expf(x); FCIMPLEND /*====================================Floor===================================== @@ -181,7 +180,7 @@ FCIMPLEND FCIMPL1_V(float, COMSingle::Log, float x) FCALL_CONTRACT; - return netintrinsics_logf(x); + return logf(x); FCIMPLEND /*=====================================Log2===================================== @@ -199,7 +198,7 @@ FCIMPLEND FCIMPL1_V(float, COMSingle::Log10, float x) FCALL_CONTRACT; - return netintrinsics_log10f(x); + return log10f(x); FCIMPLEND /*=====================================ModF===================================== @@ -217,7 +216,7 @@ FCIMPLEND FCIMPL2_VV(float, COMSingle::Pow, float x, float y) FCALL_CONTRACT; - return netintrinsics_powf(x, y); + return powf(x, y); FCIMPLEND /*=====================================Sin====================================== diff --git a/src/coreclr/jit/CMakeLists.txt b/src/coreclr/jit/CMakeLists.txt index 36395cc2d33670..480d9d50350ddc 100644 --- a/src/coreclr/jit/CMakeLists.txt +++ b/src/coreclr/jit/CMakeLists.txt @@ -523,7 +523,6 @@ add_custom_target(jit_exports DEPENDS ${JIT_EXPORTS_FILE}) set(JIT_LINK_LIBRARIES utilcodestaticnohost - netintrinsics ) set(JIT_ARCH_LINK_LIBRARIES diff --git a/src/coreclr/jit/jitpch.h b/src/coreclr/jit/jitpch.h index 1d4d75de34fe5e..63f12133f61bff 100644 --- a/src/coreclr/jit/jitpch.h +++ b/src/coreclr/jit/jitpch.h @@ -12,7 +12,6 @@ #include #include #include -#include "netintrinsics.h" // Don't allow using the windows.h #defines for the BitScan* APIs. Using the #defines means our // `BitOperations::BitScan*` functions have their name mapped, which is confusing and messes up diff --git a/src/coreclr/jit/static/CMakeLists.txt b/src/coreclr/jit/static/CMakeLists.txt index 27bf35f361c909..89dd2bc72e8a89 100644 --- a/src/coreclr/jit/static/CMakeLists.txt +++ b/src/coreclr/jit/static/CMakeLists.txt @@ -14,4 +14,3 @@ endif(CLR_CMAKE_HOST_UNIX) target_include_directories(clrjit_static PRIVATE ${JIT_SOURCE_DIR}) target_precompile_headers(clrjit_static PRIVATE [["jitpch.h"]]) -target_link_libraries(clrjit_static PRIVATE netintrinsics) diff --git a/src/coreclr/jit/utils.cpp b/src/coreclr/jit/utils.cpp index d17d0431f9ee80..6622cb64ba138a 100644 --- a/src/coreclr/jit/utils.cpp +++ b/src/coreclr/jit/utils.cpp @@ -3258,6 +3258,32 @@ double FloatingPointUtils::normalize(double value) #endif } +int FloatingPointUtils::ilogb(double value) +{ + if (value == 0.0) + { + return -2147483648; + } + else if (isNaN(value)) + { + return 2147483647; + } + return ilogb(value); +} + +int FloatingPointUtils::ilogb(float value) +{ + if (value == 0.0f) + { + return -2147483648; + } + else if (isNaN(value)) + { + return 2147483647; + } + return ilogbf(value); +} + //------------------------------------------------------------------------ // BitOperations::BitScanReverse: Search the mask data from most significant bit (MSB) to least significant bit // (LSB) for a set bit (1). diff --git a/src/coreclr/jit/utils.h b/src/coreclr/jit/utils.h index 766689fc49b68e..20de1ad103c61f 100644 --- a/src/coreclr/jit/utils.h +++ b/src/coreclr/jit/utils.h @@ -858,6 +858,10 @@ class FloatingPointUtils static float minimumNumber(float val1, float val2); static double normalize(double x); + + static int ilogb(double x); + + static int ilogb(float f); }; class BitOperations diff --git a/src/coreclr/jit/valuenum.cpp b/src/coreclr/jit/valuenum.cpp index 77661938fb4c73..c520e89ac866f1 100644 --- a/src/coreclr/jit/valuenum.cpp +++ b/src/coreclr/jit/valuenum.cpp @@ -8266,7 +8266,7 @@ ValueNum ValueNumStore::EvalMathFuncUnary(var_types typ, NamedIntrinsic gtMathFN break; case NI_System_Math_Acos: - res = netintrinsics_acos(arg0Val); + res = acos(arg0Val); break; case NI_System_Math_Acosh: @@ -8274,7 +8274,7 @@ ValueNum ValueNumStore::EvalMathFuncUnary(var_types typ, NamedIntrinsic gtMathFN break; case NI_System_Math_Asin: - res = netintrinsics_asin(arg0Val); + res = asin(arg0Val); break; case NI_System_Math_Asinh: @@ -8306,7 +8306,7 @@ ValueNum ValueNumStore::EvalMathFuncUnary(var_types typ, NamedIntrinsic gtMathFN break; case NI_System_Math_Exp: - res = netintrinsics_exp(arg0Val); + res = exp(arg0Val); break; case NI_System_Math_Floor: @@ -8314,7 +8314,7 @@ ValueNum ValueNumStore::EvalMathFuncUnary(var_types typ, NamedIntrinsic gtMathFN break; case NI_System_Math_Log: - res = netintrinsics_log(arg0Val); + res = log(arg0Val); break; case NI_System_Math_Log2: @@ -8322,7 +8322,7 @@ ValueNum ValueNumStore::EvalMathFuncUnary(var_types typ, NamedIntrinsic gtMathFN break; case NI_System_Math_Log10: - res = netintrinsics_log10(arg0Val); + res = log10(arg0Val); break; case NI_System_Math_Sin: @@ -8374,7 +8374,7 @@ ValueNum ValueNumStore::EvalMathFuncUnary(var_types typ, NamedIntrinsic gtMathFN break; case NI_System_Math_Acos: - res = netintrinsics_acosf(arg0Val); + res = acosf(arg0Val); break; case NI_System_Math_Acosh: @@ -8382,7 +8382,7 @@ ValueNum ValueNumStore::EvalMathFuncUnary(var_types typ, NamedIntrinsic gtMathFN break; case NI_System_Math_Asin: - res = netintrinsics_asinf(arg0Val); + res = asinf(arg0Val); break; case NI_System_Math_Asinh: @@ -8414,7 +8414,7 @@ ValueNum ValueNumStore::EvalMathFuncUnary(var_types typ, NamedIntrinsic gtMathFN break; case NI_System_Math_Exp: - res = netintrinsics_expf(arg0Val); + res = expf(arg0Val); break; case NI_System_Math_Floor: @@ -8422,7 +8422,7 @@ ValueNum ValueNumStore::EvalMathFuncUnary(var_types typ, NamedIntrinsic gtMathFN break; case NI_System_Math_Log: - res = netintrinsics_logf(arg0Val); + res = logf(arg0Val); break; case NI_System_Math_Log2: @@ -8430,7 +8430,7 @@ ValueNum ValueNumStore::EvalMathFuncUnary(var_types typ, NamedIntrinsic gtMathFN break; case NI_System_Math_Log10: - res = netintrinsics_log10f(arg0Val); + res = log10f(arg0Val); break; case NI_System_Math_Sin: @@ -8480,14 +8480,14 @@ ValueNum ValueNumStore::EvalMathFuncUnary(var_types typ, NamedIntrinsic gtMathFN case TYP_DOUBLE: { double arg0Val = GetConstantDouble(arg0VN); - res = netintrinsics_ilogb(arg0Val); + res = FloatingPointUtils::ilogb(arg0Val); break; } case TYP_FLOAT: { float arg0Val = GetConstantSingle(arg0VN); - res = netintrinsics_ilogbf(arg0Val); + res = FloatingPointUtils::ilogb(arg0Val); break; } @@ -8652,7 +8652,7 @@ ValueNum ValueNumStore::EvalMathFuncBinary(var_types typ, NamedIntrinsic gtMathF { assert(typ == TypeOfVN(arg1VN)); double arg1Val = GetConstantDouble(arg1VN); - res = netintrinsics_atan2(arg0Val, arg1Val); + res = atan2(arg0Val, arg1Val); break; } @@ -8668,7 +8668,7 @@ ValueNum ValueNumStore::EvalMathFuncBinary(var_types typ, NamedIntrinsic gtMathF { assert(typ == TypeOfVN(arg1VN)); double arg1Val = GetConstantDouble(arg1VN); - res = netintrinsics_pow(arg0Val, arg1Val); + res = pow(arg0Val, arg1Val); break; } @@ -8757,7 +8757,7 @@ ValueNum ValueNumStore::EvalMathFuncBinary(var_types typ, NamedIntrinsic gtMathF { assert(typ == TypeOfVN(arg1VN)); float arg1Val = GetConstantSingle(arg1VN); - res = netintrinsics_atan2f(arg0Val, arg1Val); + res = atan2f(arg0Val, arg1Val); break; } @@ -8837,7 +8837,7 @@ ValueNum ValueNumStore::EvalMathFuncBinary(var_types typ, NamedIntrinsic gtMathF { assert(typ == TypeOfVN(arg1VN)); float arg1Val = GetConstantSingle(arg1VN); - res = netintrinsics_powf(arg0Val, arg1Val); + res = powf(arg0Val, arg1Val); break; } diff --git a/src/coreclr/nativeaot/Runtime/Full/CMakeLists.txt b/src/coreclr/nativeaot/Runtime/Full/CMakeLists.txt index 49f466c3226d38..e665a6c88ee10b 100644 --- a/src/coreclr/nativeaot/Runtime/Full/CMakeLists.txt +++ b/src/coreclr/nativeaot/Runtime/Full/CMakeLists.txt @@ -28,11 +28,9 @@ endif (CLR_CMAKE_TARGET_WIN32) add_library(Runtime.WorkstationGC STATIC ${COMMON_RUNTIME_SOURCES} ${FULL_RUNTIME_SOURCES} ${RUNTIME_SOURCES_ARCH_ASM} ${RUNTIME_ARCH_ASM_OBJECTS}) add_dependencies(Runtime.WorkstationGC aot_eventing_headers) -target_link_libraries(Runtime.WorkstationGC PUBLIC netintrinsics) add_library(Runtime.ServerGC STATIC ${COMMON_RUNTIME_SOURCES} ${FULL_RUNTIME_SOURCES} ${RUNTIME_SOURCES_ARCH_ASM} ${SERVER_GC_SOURCES} ${RUNTIME_ARCH_ASM_OBJECTS}) add_dependencies(Runtime.ServerGC aot_eventing_headers) -target_link_libraries(Runtime.ServerGC PUBLIC netintrinsics) add_library(standalonegc-disabled STATIC ${STANDALONEGC_DISABLED_SOURCES}) add_dependencies(standalonegc-disabled aot_eventing_headers) @@ -60,7 +58,6 @@ if (CLR_CMAKE_TARGET_WIN32) add_dependencies(standalonegc-enabled.GuardCF aot_eventing_headers) add_dependencies(standalonegc-enabled.GuardCF aot_etw_headers) add_library(Runtime.ServerGC.GuardCF STATIC ${COMMON_RUNTIME_SOURCES} ${FULL_RUNTIME_SOURCES} ${RUNTIME_SOURCES_ARCH_ASM} ${SERVER_GC_SOURCES} ${RUNTIME_ARCH_ASM_OBJECTS}) - target_link_libraries(Runtime.ServerGC.GuardCF PUBLIC netintrinsics) target_compile_definitions(Runtime.ServerGC.GuardCF PRIVATE -DFEATURE_SVR_GC) set_target_properties(Runtime.ServerGC.GuardCF PROPERTIES CLR_CONTROL_FLOW_GUARD ON) diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/RuntimeImports.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/RuntimeImports.cs index 4c4171e05433a5..5f1211b5059fc3 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/RuntimeImports.cs +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/RuntimeImports.cs @@ -847,12 +847,12 @@ internal static partial void NativeRuntimeEventSource_LogWaitHandleWaitStart( [Intrinsic] [MethodImplAttribute(MethodImplOptions.InternalCall)] - [RuntimeImport(RuntimeLibrary, "netintrinsics_acos")] + [RuntimeImport(RuntimeLibrary, "acos")] internal static extern double acos(double x); [Intrinsic] [MethodImplAttribute(MethodImplOptions.InternalCall)] - [RuntimeImport(RuntimeLibrary, "netintrinsics_acosf")] + [RuntimeImport(RuntimeLibrary, "acosf")] internal static extern float acosf(float x); [Intrinsic] @@ -867,12 +867,12 @@ internal static partial void NativeRuntimeEventSource_LogWaitHandleWaitStart( [Intrinsic] [MethodImplAttribute(MethodImplOptions.InternalCall)] - [RuntimeImport(RuntimeLibrary, "netintrinsics_asin")] + [RuntimeImport(RuntimeLibrary, "asin")] internal static extern double asin(double x); [Intrinsic] [MethodImplAttribute(MethodImplOptions.InternalCall)] - [RuntimeImport(RuntimeLibrary, "netintrinsics_asinf")] + [RuntimeImport(RuntimeLibrary, "asinf")] internal static extern float asinf(float x); [Intrinsic] @@ -897,12 +897,12 @@ internal static partial void NativeRuntimeEventSource_LogWaitHandleWaitStart( [Intrinsic] [MethodImplAttribute(MethodImplOptions.InternalCall)] - [RuntimeImport(RuntimeLibrary, "netintrinsics_atan2")] + [RuntimeImport(RuntimeLibrary, "atan2")] internal static extern double atan2(double y, double x); [Intrinsic] [MethodImplAttribute(MethodImplOptions.InternalCall)] - [RuntimeImport(RuntimeLibrary, "netintrinsics_atan2f")] + [RuntimeImport(RuntimeLibrary, "atan2f")] internal static extern float atan2f(float y, float x); [Intrinsic] @@ -957,12 +957,12 @@ internal static partial void NativeRuntimeEventSource_LogWaitHandleWaitStart( [Intrinsic] [MethodImplAttribute(MethodImplOptions.InternalCall)] - [RuntimeImport(RuntimeLibrary, "netintrinsics_exp")] + [RuntimeImport(RuntimeLibrary, "exp")] internal static extern double exp(double x); [Intrinsic] [MethodImplAttribute(MethodImplOptions.InternalCall)] - [RuntimeImport(RuntimeLibrary, "netintrinsics_expf")] + [RuntimeImport(RuntimeLibrary, "expf")] internal static extern float expf(float x); [Intrinsic] @@ -977,12 +977,12 @@ internal static partial void NativeRuntimeEventSource_LogWaitHandleWaitStart( [Intrinsic] [MethodImplAttribute(MethodImplOptions.InternalCall)] - [RuntimeImport(RuntimeLibrary, "netintrinsics_log")] + [RuntimeImport(RuntimeLibrary, "log")] internal static extern double log(double x); [Intrinsic] [MethodImplAttribute(MethodImplOptions.InternalCall)] - [RuntimeImport(RuntimeLibrary, "netintrinsics_logf")] + [RuntimeImport(RuntimeLibrary, "logf")] internal static extern float logf(float x); [Intrinsic] @@ -997,22 +997,22 @@ internal static partial void NativeRuntimeEventSource_LogWaitHandleWaitStart( [Intrinsic] [MethodImplAttribute(MethodImplOptions.InternalCall)] - [RuntimeImport(RuntimeLibrary, "netintrinsics_log10")] + [RuntimeImport(RuntimeLibrary, "log10")] internal static extern double log10(double x); [Intrinsic] [MethodImplAttribute(MethodImplOptions.InternalCall)] - [RuntimeImport(RuntimeLibrary, "netintrinsics_log10f")] + [RuntimeImport(RuntimeLibrary, "log10f")] internal static extern float log10f(float x); [Intrinsic] [MethodImplAttribute(MethodImplOptions.InternalCall)] - [RuntimeImport(RuntimeLibrary, "netintrinsics_pow")] + [RuntimeImport(RuntimeLibrary, "pow")] internal static extern double pow(double x, double y); [Intrinsic] [MethodImplAttribute(MethodImplOptions.InternalCall)] - [RuntimeImport(RuntimeLibrary, "netintrinsics_powf")] + [RuntimeImport(RuntimeLibrary, "powf")] internal static extern float powf(float x, float y); [Intrinsic] diff --git a/src/mono/CMakeLists.txt b/src/mono/CMakeLists.txt index 8d4c3ccfc1a021..d5374b3bca6a8a 100644 --- a/src/mono/CMakeLists.txt +++ b/src/mono/CMakeLists.txt @@ -975,8 +975,6 @@ endif() include_directories("${CLR_SRC_NATIVE_DIR}") -add_subdirectory(${CLR_SRC_NATIVE_DIR}/netintrinsics netintrinsics) - if(NOT DISABLE_LIBS) set(INSTALL_MONO_API 1) endif() diff --git a/src/mono/mono/metadata/CMakeLists.txt b/src/mono/mono/metadata/CMakeLists.txt index 9d0e54d4159415..a98f21069427ab 100644 --- a/src/mono/mono/metadata/CMakeLists.txt +++ b/src/mono/mono/metadata/CMakeLists.txt @@ -202,7 +202,7 @@ set(metadata_sources "${metadata_platform_sources};${metadata_common_sources};${ if(HOST_WIN32 AND NOT DISABLE_SHARED_LIBS) add_library(metadata_objects_shared OBJECT ${metadata_sources}) target_compile_definitions(metadata_objects_shared PRIVATE ${metadata_compile_definitions}) - target_link_libraries(metadata_objects_shared PRIVATE monoapi eglib_api utils_objects_shared netintrinsics) + target_link_libraries(metadata_objects_shared PRIVATE monoapi eglib_api utils_objects_shared) # note: metadata_objects is an object library, so this doesn't force linking with sgen, # it just adds the relevant include directories - which we need even with Boehm target_link_libraries(metadata_objects_shared PRIVATE sgen_objects_shared) @@ -214,7 +214,7 @@ endif() add_library(metadata_objects OBJECT ${metadata_sources}) target_compile_definitions(metadata_objects PRIVATE ${metadata_compile_definitions}) -target_link_libraries(metadata_objects PRIVATE monoapi eglib_api utils_objects netintrinsics) +target_link_libraries(metadata_objects PRIVATE monoapi eglib_api utils_objects) # note: metadata_objects is an object library, so this doesn't force linking with sgen, # it just adds the relevant include directories - which we need even with Boehm target_link_libraries(metadata_objects PRIVATE sgen_objects) diff --git a/src/mono/mono/metadata/sysmath.c b/src/mono/mono/metadata/sysmath.c index 4b9b48fba1e419..b7c6006da692cd 100644 --- a/src/mono/mono/metadata/sysmath.c +++ b/src/mono/mono/metadata/sysmath.c @@ -25,7 +25,6 @@ #define __USE_ISOC99 #include -#include #include "utils/mono-compiler.h" #include "utils/mono-math.h" @@ -101,7 +100,7 @@ ves_icall_System_Math_Tanh (gdouble x) gdouble ves_icall_System_Math_Acos (gdouble x) { - return netintrinsics_acos (x); + return acos (x); } gdouble @@ -113,7 +112,7 @@ ves_icall_System_Math_Acosh (gdouble x) gdouble ves_icall_System_Math_Asin (gdouble x) { - return netintrinsics_asin (x); + return asin (x); } gdouble @@ -131,7 +130,7 @@ ves_icall_System_Math_Atan (gdouble x) gdouble ves_icall_System_Math_Atan2 (gdouble y, gdouble x) { - return netintrinsics_atan2 (y, x); + return atan2 (y, x); } gdouble @@ -143,25 +142,25 @@ ves_icall_System_Math_Atanh (gdouble x) gdouble ves_icall_System_Math_Exp (gdouble x) { - return netintrinsics_exp (x); + return exp (x); } gdouble ves_icall_System_Math_Log (gdouble x) { - return netintrinsics_log (x); + return log (x); } gdouble ves_icall_System_Math_Log10 (gdouble x) { - return netintrinsics_log10 (x); + return log10 (x); } gdouble ves_icall_System_Math_Pow (gdouble x, gdouble y) { - return netintrinsics_pow (x, y); + return pow (x, y); } gdouble @@ -191,7 +190,7 @@ ves_icall_System_Math_FusedMultiplyAdd (gdouble x, gdouble y, gdouble z) float ves_icall_System_MathF_Acos (float x) { - return netintrinsics_acosf (x); + return acosf (x); } float @@ -203,7 +202,7 @@ ves_icall_System_MathF_Acosh (float x) float ves_icall_System_MathF_Asin (float x) { - return netintrinsics_asinf (x); + return asinf (x); } float @@ -221,7 +220,7 @@ ves_icall_System_MathF_Atan (float x) float ves_icall_System_MathF_Atan2 (float x, float y) { - return netintrinsics_atan2f (x, y); + return atan2f (x, y); } float @@ -257,7 +256,7 @@ ves_icall_System_MathF_Cosh (float x) float ves_icall_System_MathF_Exp (float x) { - return netintrinsics_expf (x); + return expf (x); } float @@ -269,19 +268,19 @@ ves_icall_System_MathF_Floor (float x) float ves_icall_System_MathF_Log (float x) { - return netintrinsics_logf (x); + return logf (x); } float ves_icall_System_MathF_Log10 (float x) { - return netintrinsics_log10f (x); + return log10f (x); } float ves_icall_System_MathF_Pow (float x, float y) { - return netintrinsics_powf (x, y); + return powf (x, y); } float diff --git a/src/mono/mono/mini/CMakeLists.txt b/src/mono/mono/mini/CMakeLists.txt index a7be298c831841..c5b6596e7e5624 100644 --- a/src/mono/mono/mini/CMakeLists.txt +++ b/src/mono/mono/mini/CMakeLists.txt @@ -337,7 +337,7 @@ endif() if(ENABLE_INTERP_LIB) add_library(mono-ee-interp STATIC "${interp_sources}") target_link_libraries(mono-ee-interp PRIVATE monoapi eglib_api) -target_link_libraries(mono-ee-interp PUBLIC netintrinsics) +target_link_libraries(mono-ee-interp PUBLIC) target_include_directories(mono-ee-interp PRIVATE ${PROJECT_BINARY_DIR}/../.. ${PROJECT_SOURCE_DIR}/../.. ${PROJECT_SOURCE_DIR}/..) @@ -395,18 +395,18 @@ set(monosgen-sources "${mini_sources};${ZLIB_SOURCES}") if(HOST_WIN32 AND NOT DISABLE_SHARED_LIBS) add_library(monosgen-objects_shared OBJECT "${monosgen-sources}") target_compile_definitions(monosgen-objects_shared PRIVATE -DMONO_DLL_EXPORT) - target_link_libraries (monosgen-objects_shared PRIVATE monoapi eglib_api utils_objects_shared sgen_objects_shared metadata_objects_shared netintrinsics) + target_link_libraries (monosgen-objects_shared PRIVATE monoapi eglib_api utils_objects_shared sgen_objects_shared metadata_objects_shared) endif() add_library(monosgen-objects OBJECT "${monosgen-sources}") -target_link_libraries (monosgen-objects PRIVATE monoapi eglib_api utils_objects sgen_objects metadata_objects netintrinsics) +target_link_libraries (monosgen-objects PRIVATE monoapi eglib_api utils_objects sgen_objects metadata_objects) if(NOT HOST_WIN32) target_compile_definitions(monosgen-objects PRIVATE -DMONO_DLL_EXPORT) endif() add_library(monosgen-static STATIC $ $ $ $ $) set_target_properties(monosgen-static PROPERTIES OUTPUT_NAME ${MONO_LIB_NAME}) -target_link_libraries(monosgen-static PUBLIC netintrinsics) +target_link_libraries(monosgen-static PUBLIC) if(DISABLE_COMPONENTS OR AOT_COMPONENTS) # add component fallback stubs into static mono library when components have been disabled. @@ -439,7 +439,7 @@ if(NOT DISABLE_SHARED_LIBS) if(HAVE_ICU_SHIM) target_link_libraries(monosgen-shared PRIVATE icu_shim_objects) endif() - target_include_directories (monosgen-shared PRIVATE monoapi netintrinsics) + target_include_directories (monosgen-shared PRIVATE monoapi) if(TARGET_WIN32) # on Windows the import library for the shared mono library will have the same name as the static library, # to avoid a conflict we rename the import library with the .import.lib suffix diff --git a/src/mono/mono/mini/interp/interp.c b/src/mono/mono/mini/interp/interp.c index ec2e4b4323b934..23bf79620a73e2 100644 --- a/src/mono/mono/mini/interp/interp.c +++ b/src/mono/mono/mini/interp/interp.c @@ -21,7 +21,6 @@ #include #include #include -#include #include #include @@ -7623,9 +7622,9 @@ MINT_IN_CASE(MINT_BRTRUE_I8_SP) ZEROP_SP(gint64, !=); MINT_IN_BREAK; LOCAL_VAR (ip [1], double) = mathfunc (LOCAL_VAR (ip [2], double), LOCAL_VAR (ip [3], double)); \ ip += 4; - MINT_IN_CASE(MINT_ASIN) MATH_UNOP(netintrinsics_asin); MINT_IN_BREAK; + MINT_IN_CASE(MINT_ASIN) MATH_UNOP(asin); MINT_IN_BREAK; MINT_IN_CASE(MINT_ASINH) MATH_UNOP(asinh); MINT_IN_BREAK; - MINT_IN_CASE(MINT_ACOS) MATH_UNOP(netintrinsics_acos); MINT_IN_BREAK; + MINT_IN_CASE(MINT_ACOS) MATH_UNOP(acos); MINT_IN_BREAK; MINT_IN_CASE(MINT_ACOSH) MATH_UNOP(acosh); MINT_IN_BREAK; MINT_IN_CASE(MINT_ATAN) MATH_UNOP(atan); MINT_IN_BREAK; MINT_IN_CASE(MINT_ATANH) MATH_UNOP(atanh); MINT_IN_BREAK; @@ -7633,11 +7632,11 @@ MINT_IN_CASE(MINT_BRTRUE_I8_SP) ZEROP_SP(gint64, !=); MINT_IN_BREAK; MINT_IN_CASE(MINT_COS) MATH_UNOP(cos); MINT_IN_BREAK; MINT_IN_CASE(MINT_CBRT) MATH_UNOP(cbrt); MINT_IN_BREAK; MINT_IN_CASE(MINT_COSH) MATH_UNOP(cosh); MINT_IN_BREAK; - MINT_IN_CASE(MINT_EXP) MATH_UNOP(netintrinsics_exp); MINT_IN_BREAK; + MINT_IN_CASE(MINT_EXP) MATH_UNOP(exp); MINT_IN_BREAK; MINT_IN_CASE(MINT_FLOOR) MATH_UNOP(floor); MINT_IN_BREAK; - MINT_IN_CASE(MINT_LOG) MATH_UNOP(netintrinsics_log); MINT_IN_BREAK; + MINT_IN_CASE(MINT_LOG) MATH_UNOP(log); MINT_IN_BREAK; MINT_IN_CASE(MINT_LOG2) MATH_UNOP(log2); MINT_IN_BREAK; - MINT_IN_CASE(MINT_LOG10) MATH_UNOP(netintrinsics_log10); MINT_IN_BREAK; + MINT_IN_CASE(MINT_LOG10) MATH_UNOP(log10); MINT_IN_BREAK; MINT_IN_CASE(MINT_SIN) MATH_UNOP(sin); MINT_IN_BREAK; MINT_IN_CASE(MINT_SQRT) MATH_UNOP(sqrt); MINT_IN_BREAK; MINT_IN_CASE(MINT_SINH) MATH_UNOP(sinh); MINT_IN_BREAK; @@ -7645,8 +7644,8 @@ MINT_IN_CASE(MINT_BRTRUE_I8_SP) ZEROP_SP(gint64, !=); MINT_IN_BREAK; MINT_IN_CASE(MINT_TANH) MATH_UNOP(tanh); MINT_IN_BREAK; MINT_IN_CASE(MINT_ABS) MATH_UNOP(fabs); MINT_IN_BREAK; - MINT_IN_CASE(MINT_ATAN2) MATH_BINOP(netintrinsics_atan2); MINT_IN_BREAK; - MINT_IN_CASE(MINT_POW) MATH_BINOP(netintrinsics_pow); MINT_IN_BREAK; + MINT_IN_CASE(MINT_ATAN2) MATH_BINOP(atan2); MINT_IN_BREAK; + MINT_IN_CASE(MINT_POW) MATH_BINOP(pow); MINT_IN_BREAK; MINT_IN_CASE(MINT_MIN) MATH_BINOP(min_d); MINT_IN_BREAK; MINT_IN_CASE(MINT_MAX) MATH_BINOP(max_d); MINT_IN_BREAK; MINT_IN_CASE(MINT_FMA) @@ -7665,9 +7664,9 @@ MINT_IN_CASE(MINT_BRTRUE_I8_SP) ZEROP_SP(gint64, !=); MINT_IN_BREAK; #define MATH_BINOPF(mathfunc) \ LOCAL_VAR (ip [1], float) = mathfunc (LOCAL_VAR (ip [2], float), LOCAL_VAR (ip [3], float)); \ ip += 4; - MINT_IN_CASE(MINT_ASINF) MATH_UNOPF(netintrinsics_asinf); MINT_IN_BREAK; + MINT_IN_CASE(MINT_ASINF) MATH_UNOPF(asinf); MINT_IN_BREAK; MINT_IN_CASE(MINT_ASINHF) MATH_UNOPF(asinhf); MINT_IN_BREAK; - MINT_IN_CASE(MINT_ACOSF) MATH_UNOPF(netintrinsics_acosf); MINT_IN_BREAK; + MINT_IN_CASE(MINT_ACOSF) MATH_UNOPF(acosf); MINT_IN_BREAK; MINT_IN_CASE(MINT_ACOSHF) MATH_UNOPF(acoshf); MINT_IN_BREAK; MINT_IN_CASE(MINT_ATANF) MATH_UNOPF(atanf); MINT_IN_BREAK; MINT_IN_CASE(MINT_ATANHF) MATH_UNOPF(atanhf); MINT_IN_BREAK; @@ -7675,11 +7674,11 @@ MINT_IN_CASE(MINT_BRTRUE_I8_SP) ZEROP_SP(gint64, !=); MINT_IN_BREAK; MINT_IN_CASE(MINT_COSF) MATH_UNOPF(cosf); MINT_IN_BREAK; MINT_IN_CASE(MINT_CBRTF) MATH_UNOPF(cbrtf); MINT_IN_BREAK; MINT_IN_CASE(MINT_COSHF) MATH_UNOPF(coshf); MINT_IN_BREAK; - MINT_IN_CASE(MINT_EXPF) MATH_UNOPF(netintrinsics_expf); MINT_IN_BREAK; + MINT_IN_CASE(MINT_EXPF) MATH_UNOPF(expf); MINT_IN_BREAK; MINT_IN_CASE(MINT_FLOORF) MATH_UNOPF(floorf); MINT_IN_BREAK; - MINT_IN_CASE(MINT_LOGF) MATH_UNOPF(netintrinsics_logf); MINT_IN_BREAK; + MINT_IN_CASE(MINT_LOGF) MATH_UNOPF(logf); MINT_IN_BREAK; MINT_IN_CASE(MINT_LOG2F) MATH_UNOPF(log2f); MINT_IN_BREAK; - MINT_IN_CASE(MINT_LOG10F) MATH_UNOPF(netintrinsics_log10f); MINT_IN_BREAK; + MINT_IN_CASE(MINT_LOG10F) MATH_UNOPF(log10f); MINT_IN_BREAK; MINT_IN_CASE(MINT_SINF) MATH_UNOPF(sinf); MINT_IN_BREAK; MINT_IN_CASE(MINT_SQRTF) MATH_UNOPF(sqrtf); MINT_IN_BREAK; MINT_IN_CASE(MINT_SINHF) MATH_UNOPF(sinhf); MINT_IN_BREAK; @@ -7687,8 +7686,8 @@ MINT_IN_CASE(MINT_BRTRUE_I8_SP) ZEROP_SP(gint64, !=); MINT_IN_BREAK; MINT_IN_CASE(MINT_TANHF) MATH_UNOPF(tanhf); MINT_IN_BREAK; MINT_IN_CASE(MINT_ABSF) MATH_UNOPF(fabsf); MINT_IN_BREAK; - MINT_IN_CASE(MINT_ATAN2F) MATH_BINOPF(netintrinsics_atan2f); MINT_IN_BREAK; - MINT_IN_CASE(MINT_POWF) MATH_BINOPF(netintrinsics_powf); MINT_IN_BREAK; + MINT_IN_CASE(MINT_ATAN2F) MATH_BINOPF(atan2f); MINT_IN_BREAK; + MINT_IN_CASE(MINT_POWF) MATH_BINOPF(powf); MINT_IN_BREAK; MINT_IN_CASE(MINT_MINF) MATH_BINOPF(min_f); MINT_IN_BREAK; MINT_IN_CASE(MINT_MAXF) MATH_BINOPF(max_f); MINT_IN_BREAK; MINT_IN_CASE(MINT_FMAF) diff --git a/src/mono/mono/mini/intrinsics.c b/src/mono/mono/mini/intrinsics.c index d58e8213268957..1c1dede53bc5e8 100644 --- a/src/mono/mono/mini/intrinsics.c +++ b/src/mono/mono/mini/intrinsics.c @@ -7,7 +7,6 @@ #include #include #include -#include #ifndef DISABLE_JIT @@ -1865,13 +1864,13 @@ mini_emit_inst_for_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSign result = fabs (source); break; case OP_ACOS: - result = netintrinsics_acos (source); + result = acos (source); break; case OP_ACOSH: result = acosh (source); break; case OP_ASIN: - result = netintrinsics_asin (source); + result = asin (source); break; case OP_ASINH: result= asinh (source); diff --git a/src/native/corehost/apphost/static/CMakeLists.txt b/src/native/corehost/apphost/static/CMakeLists.txt index 03e7e7a6559eb6..7a14c7c92ed668 100644 --- a/src/native/corehost/apphost/static/CMakeLists.txt +++ b/src/native/corehost/apphost/static/CMakeLists.txt @@ -118,8 +118,6 @@ if(CLR_CMAKE_TARGET_WIN32) System.Globalization.Native-Static System.IO.Compression.Native-Static - netintrinsics - kernel32.lib advapi32.lib ole32.lib @@ -150,8 +148,6 @@ else() System.Native-Static System.Security.Cryptography.Native.OpenSsl-Static - netintrinsics - palrt coreclrpal_dac corguids diff --git a/src/native/netintrinsics/CMakeLists.txt b/src/native/netintrinsics/CMakeLists.txt deleted file mode 100644 index 57f504f7b2c11c..00000000000000 --- a/src/native/netintrinsics/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -set(SOURCES math.c) - -include(configure.cmake) - -add_library(netintrinsics OBJECT ${SOURCES}) - -target_include_directories(netintrinsics PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) -target_include_directories(netintrinsics PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) \ No newline at end of file diff --git a/src/native/netintrinsics/config.h.in b/src/native/netintrinsics/config.h.in deleted file mode 100644 index 18e78b33f5253a..00000000000000 --- a/src/native/netintrinsics/config.h.in +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef NETINTRINSICS_CONFIG_H_INCLUDED -#define NETINTRINSICS_CONFIG_H_INCLUDED - -#cmakedefine01 HAVE_IEEEFP_H -#cmakedefine01 HAVE_COMPATIBLE_ACOS -#cmakedefine01 HAVE_COMPATIBLE_ASIN -#cmakedefine01 HAVE_COMPATIBLE_POW -#cmakedefine01 HAVE_VALID_NEGATIVE_INF_POW -#cmakedefine01 HAVE_VALID_POSITIVE_INF_POW -#cmakedefine01 HAVE_COMPATIBLE_ATAN2 -#cmakedefine01 HAVE_COMPATIBLE_EXP -#cmakedefine01 HAVE_COMPATIBLE_ILOGB0 -#cmakedefine01 HAVE_COMPATIBLE_ILOGBNAN -#cmakedefine01 HAVE_COMPATIBLE_LOG -#cmakedefine01 HAVE_COMPATIBLE_LOG10 - -#endif // NETINTRINSICS_CONFIG_H_INCLUDED diff --git a/src/native/netintrinsics/configure.cmake b/src/native/netintrinsics/configure.cmake deleted file mode 100644 index 528aa3e9959af7..00000000000000 --- a/src/native/netintrinsics/configure.cmake +++ /dev/null @@ -1,200 +0,0 @@ -include(CheckCSourceRuns) -include(CheckIncludeFile) - -if(CLR_CMAKE_TARGET_FREEBSD) - set(CMAKE_REQUIRED_INCLUDES ${CROSS_ROOTFS}/usr/local/include) -elseif(CLR_CMAKE_TARGET_SUNOS) - set(CMAKE_REQUIRED_INCLUDES /opt/local/include) -endif() - -check_include_file(ieeefp.h HAVE_IEEEFP_H) - -set(CMAKE_REQUIRED_LIBRARIES m) -check_c_source_runs(" -#include -#include - -int main(void) { - volatile double x = 10; - if (!isnan(acos(x))) { - exit(1); - } - exit(0); -}" HAVE_COMPATIBLE_ACOS) -check_c_source_runs(" -#include -#include - -int main(void) { - volatile double arg = 10; - if (!isnan(asin(arg))) { - exit(1); - } - exit(0); -}" HAVE_COMPATIBLE_ASIN) -check_c_source_runs(" -#include -#include - -int main(void) { - volatile double base = 1.0; - volatile double infinity = 1.0 / 0.0; - if (pow(base, infinity) != 1.0 || pow(base, -infinity) != 1.0) { - exit(1); - } - if (pow(-base, infinity) != 1.0 || pow(-base, -infinity) != 1.0) { - exit(1); - } - - base = 0.0; - if (pow(base, infinity) != 0.0) { - exit(1); - } - if (pow(base, -infinity) != infinity) { - exit(1); - } - - base = 1.1; - if (pow(-base, infinity) != infinity || pow(base, infinity) != infinity) { - exit(1); - } - if (pow(-base, -infinity) != 0.0 || pow(base, -infinity) != 0.0) { - exit(1); - } - - base = 0.0; - volatile int iexp = 1; - if (pow(-base, -iexp) != -infinity) { - exit(1); - } - if (pow(base, -iexp) != infinity) { - exit(1); - } - exit(0); -}" HAVE_COMPATIBLE_POW) -check_c_source_runs(" -#include -#include - -int main(int argc, char **argv) { - double result; - volatile double base = 3.2e-10; - volatile double exp = 1 - 5e14; - - result = pow(-base, exp); - if (result != -1.0 / 0.0) { - exit(1); - } - exit(0); -}" HAVE_VALID_NEGATIVE_INF_POW) -check_c_source_runs(" -#include -#include - -int main(int argc, char **argv) { - double result; - volatile double base = 3.5; - volatile double exp = 3e100; - - result = pow(-base, exp); - if (result != 1.0 / 0.0) { - exit(1); - } - exit(0); -}" HAVE_VALID_POSITIVE_INF_POW) -check_c_source_runs(" -#include -#include - -int main(void) { - double pi = 3.14159265358979323846; - double result; - volatile double y = 0.0; - volatile double x = 0.0; - - result = atan2(y, -x); - if (fabs(pi - result) > 0.0000001) { - exit(1); - } - - result = atan2(-y, -x); - if (fabs(-pi - result) > 0.0000001) { - exit(1); - } - - result = atan2 (-y, x); - if (result != 0.0 || copysign (1.0, result) > 0) { - exit(1); - } - - result = atan2 (y, x); - if (result != 0.0 || copysign (1.0, result) < 0) { - exit(1); - } - - exit (0); -}" HAVE_COMPATIBLE_ATAN2) -check_c_source_runs(" -#include -#include - -int main(void) { - double d = exp(1.0), e = M_E; - - /* Used memcmp rather than == to test that the doubles are equal to - prevent gcc's optimizer from using its 80 bit internal long - doubles. If you use ==, then on BSD you get a false negative since - exp(1.0) == M_E to 64 bits, but not 80. - */ - - if (memcmp (&d, &e, sizeof (double)) == 0) { - exit(0); - } - exit(1); -}" HAVE_COMPATIBLE_EXP) -check_c_source_runs(" -#include -#include - -int main(void) { - if (FP_ILOGB0 != -2147483648) { - exit(1); - } - - exit(0); -}" HAVE_COMPATIBLE_ILOGB0) -check_c_source_runs(" -#include -#include - -int main(void) { - if (FP_ILOGBNAN != 2147483647) { - exit(1); - } - - exit(0); -}" HAVE_COMPATIBLE_ILOGBNAN) -check_c_source_runs(" -#include -#include - -int main(void) { - volatile int arg = 10000; - if (!isnan(log(-arg))) { - exit(1); - } - exit(0); -}" HAVE_COMPATIBLE_LOG) -check_c_source_runs(" -#include -#include - -int main(void) { - volatile int arg = 10000; - if (!isnan(log10(-arg))) { - exit(1); - } - exit(0); -}" HAVE_COMPATIBLE_LOG10) - -configure_file(${CMAKE_CURRENT_LIST_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h) diff --git a/src/native/netintrinsics/math.c b/src/native/netintrinsics/math.c deleted file mode 100644 index 0e20c23495c349..00000000000000 --- a/src/native/netintrinsics/math.c +++ /dev/null @@ -1,515 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*++ - - - -Module Name: - - math.cpp - -Abstract: - - Implementation of math family functions. - - - ---*/ - -#include -#include - -#if HAVE_IEEEFP_H -#include -#endif // HAVE_IEEEFP_H - -#include -#include "config.h" - -#define PAL_NAN_DBL sqrt(-1.0) -#define PAL_POSINF_DBL -log(0.0) -#define PAL_NEGINF_DBL log(0.0) - -#define IS_DBL_NEGZERO(x) (((*((int64_t*)((void*)&x))) & 0xFFFFFFFFFFFFFFFFLL) == 0x8000000000000000LL) - -#define PAL_NAN_FLT sqrtf(-1.0f) -#define PAL_POSINF_FLT -logf(0.0f) -#define PAL_NEGINF_FLT logf(0.0f) - -#define IS_FLT_NEGZERO(x) (((*((INT32*)((void*)&x))) & 0xFFFFFFFF) == 0x80000000) - -double netintrinsics_acos(double x) -{ - double ret; - -#if !HAVE_COMPATIBLE_ACOS - errno = 0; -#endif // HAVE_COMPATIBLE_ACOS - - ret = acos(x); - -#if !HAVE_COMPATIBLE_ACOS - if (errno == EDOM) - { - ret = PAL_NAN_DBL; // NaN - } -#endif // HAVE_COMPATIBLE_ACOS - - return ret; -} - -double netintrinsics_asin(double x) -{ - double ret; - -#if !HAVE_COMPATIBLE_ASIN - errno = 0; -#endif // HAVE_COMPATIBLE_ASIN - - ret = asin(x); - -#if !HAVE_COMPATIBLE_ASIN - if (errno == EDOM) - { - ret = PAL_NAN_DBL; // NaN - } -#endif // HAVE_COMPATIBLE_ASIN - - return ret; -} - -double netintrinsics_atan2(double y, double x) -{ - double ret; - -#if !HAVE_COMPATIBLE_ATAN2 - errno = 0; -#endif // !HAVE_COMPATIBLE_ATAN2 - - ret = atan2(y, x); - -#if !HAVE_COMPATIBLE_ATAN2 - if ((errno == EDOM) && (x == 0.0) && (y == 0.0)) - { - const double sign_x = copysign(1.0, x); - const double sign_y = copysign(1.0, y); - - if (sign_x > 0) - { - ret = copysign(0.0, sign_y); - } - else - { - ret = copysign(atan2(0.0, -1.0), sign_y); - } - } -#endif // !HAVE_COMPATIBLE_ATAN2 - - return ret; -} - -double netintrinsics_exp(double x) -{ - double ret; - -#if !HAVE_COMPATIBLE_EXP - if (x == 1.0) - { - ret = M_E; - } - else - { -#endif // HAVE_COMPATIBLE_EXP - - ret = exp(x); - -#if !HAVE_COMPATIBLE_EXP - } -#endif // HAVE_COMPATIBLE_EXP - - return ret; -} - -int netintrinsics_ilogb(double x) -{ - int ret; -#if !HAVE_COMPATIBLE_ILOGB0 - if (x == 0.0) - { - ret = -2147483648; - } - else -#endif // !HAVE_COMPATIBLE_ILOGB0 - -#if !HAVE_COMPATIBLE_ILOGBNAN - if (isnan(x)) - { - ret = 2147483647; - } - else -#endif // !HAVE_COMPATIBLE_ILOGBNAN - - { - ret = ilogb(x); - } - return ret; -} - -double netintrinsics_log(double x) -{ - double ret; -#if !HAVE_COMPATIBLE_LOG - errno = 0; -#endif // !HAVE_COMPATIBLE_LOG - - ret = log(x); - -#if !HAVE_COMPATIBLE_LOG - if ((errno == EDOM) && (x < 0)) - { - ret = PAL_NAN_DBL; // NaN - } -#endif // !HAVE_COMPATIBLE_LOG - - return ret; -} - -double netintrinsics_log10(double x) -{ - double ret; - -#if !HAVE_COMPATIBLE_LOG10 - errno = 0; -#endif // !HAVE_COMPATIBLE_LOG10 - - ret = log10(x); - -#if !HAVE_COMPATIBLE_LOG10 - if ((errno == EDOM) && (x < 0)) - { - ret = PAL_NAN_DBL; // NaN - } -#endif // !HAVE_COMPATIBLE_LOG10 - - return ret; -} - -double netintrinsics_pow(double x, double y) -{ - double ret; - -#if !HAVE_COMPATIBLE_POW - if ((y == PAL_POSINF_DBL) && !isnan(x)) // +Inf - { - if (x == 1.0) - { - ret = x; - } - else if (x == -1.0) - { - ret = 1.0; - } - else if ((x > -1.0) && (x < 1.0)) - { - ret = 0.0; - } - else - { - ret = PAL_POSINF_DBL; // +Inf - } - } - else if ((y == PAL_NEGINF_DBL) && !isnan(x)) // -Inf - { - if (x == 1.0) - { - ret = x; - } - else if (x == -1.0) - { - ret = 1.0; - } - else if ((x > -1.0) && (x < 1.0)) - { - ret = PAL_POSINF_DBL; // +Inf - } - else - { - ret = 0.0; - } - } - else if (IS_DBL_NEGZERO(x) && (y == -1.0)) - { - ret = PAL_NEGINF_DBL; // -Inf - } - else if ((x == 0.0) && (y < 0.0)) - { - ret = PAL_POSINF_DBL; // +Inf - } - else -#endif // !HAVE_COMPATIBLE_POW - - ret = pow(x, y); - -#if !HAVE_VALID_NEGATIVE_INF_POW - if ((ret == PAL_POSINF_DBL) && (x < 0) && isfinite(x) && (ceil(y / 2) != floor(y / 2))) - { - ret = PAL_NEGINF_DBL; // -Inf - } -#endif // !HAVE_VALID_NEGATIVE_INF_POW - -#if !HAVE_VALID_POSITIVE_INF_POW - /* - * The even/odd test in the if (this one and the one above) used to be ((long long) y % 2 == 0) - * on SPARC (long long) y for large y (>2**63) is always 0x7fffffff7fffffff, which - * is an odd number, so the test ((long long) y % 2 == 0) will always fail for - * large y. Since large double numbers are always even (e.g., the representation of - * 1E20+1 is the same as that of 1E20, the last .+1. is too insignificant to be part - * of the representation), this test will always return the wrong result for large y. - * - * The (ceil(y/2) == floor(y/2)) test is slower, but more robust. - */ - if ((ret == PAL_NEGINF_DBL) && (x < 0) && isfinite(x) && (ceil(y / 2) == floor(y / 2))) - { - ret = PAL_POSINF_DBL; // +Inf - } -#endif // !HAVE_VALID_POSITIVE_INF_POW - - return ret; -} - -float netintrinsics_acosf(float x) -{ - float ret; - -#if !HAVE_COMPATIBLE_ACOS - errno = 0; -#endif // HAVE_COMPATIBLE_ACOS - - ret = acosf(x); - -#if !HAVE_COMPATIBLE_ACOS - if (errno == EDOM) - { - ret = PAL_NAN_FLT; // NaN - } -#endif // HAVE_COMPATIBLE_ACOS - - return ret; -} - -float netintrinsics_asinf(float x) -{ - float ret; - -#if !HAVE_COMPATIBLE_ASIN - errno = 0; -#endif // HAVE_COMPATIBLE_ASIN - - ret = asinf(x); - -#if !HAVE_COMPATIBLE_ASIN - if (errno == EDOM) - { - ret = PAL_NAN_FLT; // NaN - } -#endif // HAVE_COMPATIBLE_ASIN - - return ret; -} - -float netintrinsics_atan2f(float y, float x) -{ - float ret; - -#if !HAVE_COMPATIBLE_ATAN2 - errno = 0; -#endif // !HAVE_COMPATIBLE_ATAN2 - - ret = atan2f(y, x); - -#if !HAVE_COMPATIBLE_ATAN2 - if ((errno == EDOM) && (x == 0.0f) && (y == 0.0f)) - { - const float sign_x = copysign(1.0f, x); - const float sign_y = copysign(1.0f, y); - - if (sign_x > 0) - { - ret = copysign(0.0f, sign_y); - } - else - { - ret = copysign(atan2f(0.0f, -1.0f), sign_y); - } - } -#endif // !HAVE_COMPATIBLE_ATAN2 - - return ret; -} - -float netintrinsics_expf(float x) -{ - float ret; - -#if !HAVE_COMPATIBLE_EXP - if (x == 1.0f) - { - ret = M_E; - } - else - { -#endif // HAVE_COMPATIBLE_EXP - - ret = expf(x); - -#if !HAVE_COMPATIBLE_EXP - } -#endif // HAVE_COMPATIBLE_EXP - - return ret; -} - -int netintrinsics_ilogbf(float x) -{ - int ret; - -#if !HAVE_COMPATIBLE_ILOGB0 - if (x == 0.0f) - { - ret = -2147483648; - } - else -#endif // !HAVE_COMPATIBLE_ILOGB0 - -#if !HAVE_COMPATIBLE_ILOGBNAN - if (isnan(x)) - { - ret = 2147483647; - } - else -#endif // !HAVE_COMPATIBLE_ILOGBNAN - - { - ret = ilogbf(x); - } - - return ret; -} - -float netintrinsics_logf(float x) -{ - float ret; - -#if !HAVE_COMPATIBLE_LOG - errno = 0; -#endif // !HAVE_COMPATIBLE_LOG - - ret = logf(x); - -#if !HAVE_COMPATIBLE_LOG - if ((errno == EDOM) && (x < 0)) - { - ret = PAL_NAN_FLT; // NaN - } -#endif // !HAVE_COMPATIBLE_LOG - - return ret; -} - -float netintrinsics_log10f(float x) -{ - float ret; - -#if !HAVE_COMPATIBLE_LOG10 - errno = 0; -#endif // !HAVE_COMPATIBLE_LOG10 - - ret = log10f(x); - -#if !HAVE_COMPATIBLE_LOG10 - if ((errno == EDOM) && (x < 0)) - { - ret = PAL_NAN_FLT; // NaN - } -#endif // !HAVE_COMPATIBLE_LOG10 - - return ret; -} - -float netintrinsics_powf(float x, float y) -{ - float ret; - -#if !HAVE_COMPATIBLE_POW - if ((y == PAL_POSINF_FLT) && !isnan(x)) // +Inf - { - if (x == 1.0f) - { - ret = x; - } - else if (x == -1.0f) - { - ret = 1.0f; - } - else if ((x > -1.0f) && (x < 1.0f)) - { - ret = 0.0f; - } - else - { - ret = PAL_POSINF_FLT; // +Inf - } - } - else if ((y == PAL_NEGINF_FLT) && !isnan(x)) // -Inf - { - if (x == 1.0f) - { - ret = x; - } - else if (x == -1.0f) - { - ret = 1.0f; - } - else if ((x > -1.0f) && (x < 1.0f)) - { - ret = PAL_POSINF_FLT; // +Inf - } - else - { - ret = 0.0f; - } - } - else if (IS_FLT_NEGZERO(x) && (y == -1.0f)) - { - ret = PAL_NEGINF_FLT; // -Inf - } - else if ((x == 0.0f) && (y < 0.0f)) - { - ret = PAL_POSINF_FLT; // +Inf - } - else -#endif // !HAVE_COMPATIBLE_POW - - ret = powf(x, y); - -#if !HAVE_VALID_NEGATIVE_INF_POW - if ((ret == PAL_POSINF_FLT) && (x < 0) && isfinite(x) && (ceilf(y / 2) != floorf(y / 2))) - { - ret = PAL_NEGINF_FLT; // -Inf - } -#endif // !HAVE_VALID_NEGATIVE_INF_POW - -#if !HAVE_VALID_POSITIVE_INF_POW - /* - * The (ceil(y/2) == floor(y/2)) test is slower, but more robust for platforms where large y - * will return the wrong result for ((long) y % 2 == 0). See PAL_pow(double) above for more details. - */ - if ((ret == PAL_NEGINF_FLT) && (x < 0) && isfinite(x) && (ceilf(y / 2) == floorf(y / 2))) - { - ret = PAL_POSINF_FLT; // +Inf - } -#endif // !HAVE_VALID_POSITIVE_INF_POW - - return ret; -} diff --git a/src/native/netintrinsics/netintrinsics.h b/src/native/netintrinsics/netintrinsics.h deleted file mode 100644 index d490ab3f232ed0..00000000000000 --- a/src/native/netintrinsics/netintrinsics.h +++ /dev/null @@ -1,45 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -#ifndef NETINTRINSICS_H -#define NETINTRINSICS_H - -#ifdef __cplusplus -extern "C" -{ -#endif -double netintrinsics_acos(double x); - -double netintrinsics_asin(double x); - -double netintrinsics_atan2(double y, double x); - -double netintrinsics_exp(double x); - -int netintrinsics_ilogb(double x); - -double netintrinsics_log(double x); - -double netintrinsics_log10(double x); - -double netintrinsics_pow(double x, double y); - -float netintrinsics_acosf(float x); - -float netintrinsics_asinf(float x); - -float netintrinsics_atan2f(float y, float x); - -float netintrinsics_expf(float x); - -int netintrinsics_ilogbf(float x); - -float netintrinsics_logf(float x); - -float netintrinsics_log10f(float x); - -float netintrinsics_powf(float x, float y); -#ifdef __cplusplus -} -#endif - -#endif // NETINTRINSICS_H \ No newline at end of file From f519041bea9dab5317333e7aa671587af2bd6e48 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Tue, 6 Feb 2024 23:54:45 +0000 Subject: [PATCH 10/18] Remove _isnan --- src/coreclr/jit/assertionprop.cpp | 10 +- src/coreclr/jit/gentree.cpp | 2 +- src/coreclr/jit/valuenum.cpp | 23 +--- src/coreclr/pal/inc/pal.h | 2 - src/coreclr/pal/src/cruntime/math.cpp | 38 ------ src/coreclr/pal/tests/palsuite/CMakeLists.txt | 2 - .../palsuite/c_runtime/_isnan/test1/test1.cpp | 114 ------------------ .../c_runtime/_isnanf/test1/test1.cpp | 114 ------------------ .../pal/tests/palsuite/compilableTests.txt | 2 - .../pal/tests/palsuite/paltestlist.txt | 2 - src/coreclr/vm/interpreter.cpp | 18 ++- src/coreclr/vm/jithelpers.cpp | 15 ++- 12 files changed, 39 insertions(+), 303 deletions(-) delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/_isnan/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/_isnanf/test1/test1.cpp diff --git a/src/coreclr/jit/assertionprop.cpp b/src/coreclr/jit/assertionprop.cpp index 9dcdc79fd25afe..067f485df64ac2 100644 --- a/src/coreclr/jit/assertionprop.cpp +++ b/src/coreclr/jit/assertionprop.cpp @@ -1368,7 +1368,7 @@ AssertionIndex Compiler::optCreateAssertion(GenTree* op1, { noway_assert(op2->gtOper == GT_CNS_DBL); /* If we have an NaN value then don't record it */ - if (_isnan(op2->AsDblCon()->DconValue())) + if (FloatingPointUtils::isNaN(op2->AsDblCon()->DconValue())) { goto DONE_ASSERTION; // Don't make an assertion } @@ -1691,8 +1691,8 @@ bool Compiler::optAssertionVnInvolvesNan(AssertionDsc* assertion) if (vnStore->IsVNConstant(vns[i])) { var_types type = vnStore->TypeOfVN(vns[i]); - if ((type == TYP_FLOAT && _isnan(vnStore->ConstantValue(vns[i])) != 0) || - (type == TYP_DOUBLE && _isnan(vnStore->ConstantValue(vns[i])) != 0)) + if ((type == TYP_FLOAT && FloatingPointUtils::isNaN(vnStore->ConstantValue(vns[i])) != 0) || + (type == TYP_DOUBLE && FloatingPointUtils::isNaN(vnStore->ConstantValue(vns[i])) != 0)) { return true; } @@ -4321,7 +4321,7 @@ GenTree* Compiler::optAssertionPropGlobal_RelOp(ASSERT_VALARG_TP assertions, Gen // which will yield a false correctly. Instead if IL had "op1 != NaN", then we already // made op1 NaN which will yield a true correctly. Note that this is irrespective of the // assertion we have made. - allowReverse = (_isnan(constant) == 0); + allowReverse = !FloatingPointUtils::isNaN(constant); } else if (op1->TypeGet() == TYP_FLOAT) { @@ -4329,7 +4329,7 @@ GenTree* Compiler::optAssertionPropGlobal_RelOp(ASSERT_VALARG_TP assertions, Gen op1->BashToConst(constant); // See comments for TYP_DOUBLE. - allowReverse = (_isnan(constant) == 0); + allowReverse = !FloatingPointUtils::isNaN(constant); } else if (op1->TypeGet() == TYP_REF) { diff --git a/src/coreclr/jit/gentree.cpp b/src/coreclr/jit/gentree.cpp index b23eb5d0eb432f..3090bea40ffde3 100644 --- a/src/coreclr/jit/gentree.cpp +++ b/src/coreclr/jit/gentree.cpp @@ -16038,7 +16038,7 @@ GenTree* Compiler::gtFoldExprConst(GenTree* tree) // For unordered operations (i.e. the GTF_RELOP_NAN_UN flag is set) // the result is always true - return 1. - if (_isnan(d1) || _isnan(d2)) + if (FloatingPointUtils::isNaN(d1) || FloatingPointUtils::isNaN(d2)) { JITDUMP("Double operator(s) is NaN\n"); diff --git a/src/coreclr/jit/valuenum.cpp b/src/coreclr/jit/valuenum.cpp index c520e89ac866f1..8c5842cdd56f27 100644 --- a/src/coreclr/jit/valuenum.cpp +++ b/src/coreclr/jit/valuenum.cpp @@ -18,17 +18,6 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX #include "valuenum.h" #include "ssaconfig.h" -// Windows x86 and Windows ARM/ARM64 may not define _isnanf() but they do define _isnan(). -// We will redirect the macros to these other functions if the macro is not defined for the -// platform. This has the side effect of a possible implicit upcasting for arguments passed. -#if (defined(HOST_X86) || defined(HOST_ARM) || defined(HOST_ARM64)) && !defined(HOST_UNIX) - -#if !defined(_isnanf) -#define _isnanf _isnan -#endif - -#endif // (defined(HOST_X86) || defined(HOST_ARM) || defined(HOST_ARM64)) && !defined(HOST_UNIX) - // We need to use target-specific NaN values when statically compute expressions. // Otherwise, cross crossgen (e.g. x86_arm) would have different binary outputs // from native crossgen (i.e. arm_arm) when the NaN got "embedded" into code. @@ -186,11 +175,11 @@ TFp FpMul(TFp value1, TFp value2) // If [value1] is infinity and [value2] is zero // the result is NaN. - if (value1 == 0 && !_finite(value2) && !_isnan(value2)) + if (value1 == 0 && !_finite(value2) && !FloatingPointUtils::isNaN(value2)) { return TFpTraits::NaN(); } - if (!_finite(value1) && !_isnan(value1) && value2 == 0) + if (!_finite(value1) && !FloatingPointUtils::isNaN(value1) && value2 == 0) { return TFpTraits::NaN(); } @@ -224,7 +213,7 @@ TFp FpDiv(TFp dividend, TFp divisor) { return TFpTraits::NaN(); } - else if (!_finite(dividend) && !_isnan(dividend) && !_finite(divisor) && !_isnan(divisor)) + else if (!_finite(dividend) && !FloatingPointUtils::isNaN(dividend) && !_finite(divisor) && !FloatingPointUtils::isNaN(divisor)) { return TFpTraits::NaN(); } @@ -247,7 +236,7 @@ TFp FpRem(TFp dividend, TFp divisor) { return TFpTraits::NaN(); } - else if (!_finite(divisor) && !_isnan(divisor)) + else if (!_finite(divisor) && !FloatingPointUtils::isNaN(divisor)) { return dividend; } @@ -817,7 +806,7 @@ int ValueNumStore::EvalComparison(VNFunc vnf, double v0, double v1) // Here we handle specialized double comparisons. // We must check for a NaN argument as they they need special handling - bool hasNanArg = (_isnan(v0) || _isnan(v1)); + bool hasNanArg = (FloatingPointUtils::isNaN(v0) || FloatingPointUtils::isNaN(v1)); if (vnf < VNF_Boundary) { @@ -881,7 +870,7 @@ int ValueNumStore::EvalComparison(VNFunc vnf, float v0, float v1) // Here we handle specialized float comparisons. // We must check for a NaN argument as they they need special handling - bool hasNanArg = (_isnanf(v0) || _isnanf(v1)); + bool hasNanArg = (FloatingPointUtils::isNaN(v0) || FloatingPointUtils::isNaN(v1)); if (vnf < VNF_Boundary) { diff --git a/src/coreclr/pal/inc/pal.h b/src/coreclr/pal/inc/pal.h index 0bdb0ff6abab07..902802796fce34 100644 --- a/src/coreclr/pal/inc/pal.h +++ b/src/coreclr/pal/inc/pal.h @@ -4193,7 +4193,6 @@ PALIMPORT long long __cdecl llabs(long long); #ifndef PAL_STDCPP_COMPAT PALIMPORT int __cdecl _finite(double); -PALIMPORT int __cdecl _isnan(double); PALIMPORT double __cdecl _copysign(double, double); PALIMPORT double __cdecl acos(double); PALIMPORT double __cdecl acosh(double) MATH_THROW_DECL; @@ -4229,7 +4228,6 @@ PALIMPORT double __cdecl tanh(double); PALIMPORT double __cdecl trunc(double); PALIMPORT int __cdecl _finitef(float); -PALIMPORT int __cdecl _isnanf(float); PALIMPORT float __cdecl _copysignf(float, float); PALIMPORT float __cdecl acosf(float); PALIMPORT float __cdecl acoshf(float) MATH_THROW_DECL; diff --git a/src/coreclr/pal/src/cruntime/math.cpp b/src/coreclr/pal/src/cruntime/math.cpp index c8f24d8079c1ab..3fa95149123aef 100644 --- a/src/coreclr/pal/src/cruntime/math.cpp +++ b/src/coreclr/pal/src/cruntime/math.cpp @@ -54,25 +54,6 @@ int __cdecl _finite(double x) return ret; } -/*++ -Function: - _isnan - -See MSDN doc ---*/ -int __cdecl _isnan(double x) -{ - int ret; - PERF_ENTRY(_isnan); - ENTRY("_isnan (x=%f)\n", x); - - ret = isnan(x); - - LOGEXIT("_isnan returns int %d\n", ret); - PERF_EXIT(_isnan); - return ret; -} - /*++ Function: _copysign @@ -122,25 +103,6 @@ int __cdecl _finitef(float x) return ret; } -/*++ -Function: - _isnanf - -See MSDN doc ---*/ -int __cdecl _isnanf(float x) -{ - int ret; - PERF_ENTRY(_isnanf); - ENTRY("_isnanf (x=%f)\n", x); - - ret = isnan(x); - - LOGEXIT("_isnanf returns int %d\n", ret); - PERF_EXIT(_isnanf); - return ret; -} - /*++ Function: _copysignf diff --git a/src/coreclr/pal/tests/palsuite/CMakeLists.txt b/src/coreclr/pal/tests/palsuite/CMakeLists.txt index 63ba70e4a2d05d..8f9cd295621154 100644 --- a/src/coreclr/pal/tests/palsuite/CMakeLists.txt +++ b/src/coreclr/pal/tests/palsuite/CMakeLists.txt @@ -175,8 +175,6 @@ add_executable_clr(paltests c_runtime/_finitef/test1/test1.cpp #c_runtime/_gcvt/test1/_gcvt.cpp #c_runtime/_gcvt/test2/test2.cpp - c_runtime/_isnan/test1/test1.cpp - c_runtime/_isnanf/test1/test1.cpp c_runtime/_itow/test1/test1.cpp c_runtime/_putenv/test1/test1.cpp c_runtime/_putenv/test2/test2.cpp diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/_isnan/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/_isnan/test1/test1.cpp deleted file mode 100644 index 98a96cc2474a4d..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/_isnan/test1/test1.cpp +++ /dev/null @@ -1,114 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: -** Test _isnan with a number of trivial values, to ensure they indicated that -** they are numbers. Then try with Positive/Negative Infinite, which should -** also be numbers. Finally set the least and most significant bits of -** the fraction to positive and negative, at which point it should return -** the true value. -** -**==========================================================================*/ - -#include - -#define TO_DOUBLE(x) (*((double*)((void*)&x))) -#define TO_I64(x) (*((INT64*)((void*)&x))) - -/* - * NaN: any double with maximum exponent (0x7ff) and non-zero fraction - */ -PALTEST(c_runtime__isnan_test1_paltest_isnan_test1, "c_runtime/_isnan/test1/paltest_isnan_test1") -{ - /* - * Initialize the PAL and return FAIL if this fails - */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - /* - * Try some trivial values - */ - if (_isnan(0.0)) - { - Fail("_isnan() incorrectly identified %f as NaN!\n", 0.0); - } - - if (_isnan(1.23456)) - { - Fail("_isnan() incorrectly identified %f as NaN!\n", 1.234567); - } - - if (_isnan(42.0)) - { - Fail("_isnan() incorrectly identified %f as NaN!\n", 42.0); - } - - UINT64 lneginf = UI64(0xfff0000000000000); - UINT64 lposinf = UI64(0x7ff0000000000000); - - double neginf = TO_DOUBLE(lneginf); - double posinf = TO_DOUBLE(lposinf); - - /* - * Try positive and negative infinity - */ - if (_isnan(neginf)) - { - Fail("_isnan() incorrectly identified negative infinity as NaN!\n"); - } - - if (_isnan(posinf)) - { - Fail("_isnan() incorrectly identified infinity as NaN!\n"); - } - - /* - * Try setting the least significant bit of the fraction, - * positive and negative - */ - UINT64 lsnan = UI64(0xfff0000000000001); - double snan = TO_DOUBLE(lsnan); - - if (!_isnan(snan)) - { - Fail("_isnan() failed to identify %I64x as NaN!\n", lsnan); - } - - UINT64 lqnan = UI64(0x7ff0000000000001); - double qnan = TO_DOUBLE(lqnan); - - if (!_isnan(qnan)) - { - Fail("_isnan() failed to identify %I64x as NaN!\n", lqnan); - } - - /* - * Try setting the most significant bit of the fraction, - * positive and negative - */ - lsnan = UI64(0xfff8000000000000); - snan = TO_DOUBLE(lsnan); - - if (!_isnan(snan)) - { - Fail ("_isnan() failed to identify %I64x as NaN!\n", lsnan); - } - - lqnan = UI64(0x7ff8000000000000); - qnan = TO_DOUBLE(lqnan); - - if (!_isnan(qnan)) - { - Fail ("_isnan() failed to identify %I64x as NaN!\n", lqnan); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/_isnanf/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/_isnanf/test1/test1.cpp deleted file mode 100644 index b46b238342adce..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/_isnanf/test1/test1.cpp +++ /dev/null @@ -1,114 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: -** Test _isnanf with a number of trivial values, to ensure they indicated that -** they are numbers. Then try with Positive/Negative Infinite, which should -** also be numbers. Finally set the least and most significant bits of -** the fraction to positive and negative, at which point it should return -** the true value. -** -**==========================================================================*/ - -#include - -#define TO_FLOAT(x) (*((float*)((void*)&x))) -#define TO_I32(x) (*((INT32*)((void*)&x))) - -/* - * NaN: any float with maximum exponent (0x7f8) and non-zero fraction - */ -PALTEST(c_runtime__isnanf_test1_paltest_isnanf_test1, "c_runtime/_isnanf/test1/paltest_isnanf_test1") -{ - /* - * Initialize the PAL and return FAIL if this fails - */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - /* - * Try some trivial values - */ - if (_isnanf(0.0f)) - { - Fail("_isnanf() incorrectly identified %f as NaN!\n", 0.0f); - } - - if (_isnanf(1.234567f)) - { - Fail("_isnanf() incorrectly identified %f as NaN!\n", 1.234567f); - } - - if (_isnanf(42.0f)) - { - Fail("_isnanf() incorrectly identified %f as NaN!\n", 42.0f); - } - - UINT32 lneginf = 0xff800000u; - UINT32 lposinf = 0x7f800000u; - - float neginf = TO_FLOAT(lneginf); - float posinf = TO_FLOAT(lposinf); - - /* - * Try positive and negative infinity - */ - if (_isnanf(neginf)) - { - Fail("_isnanf() incorrectly identified negative infinity as NaN!\n"); - } - - if (_isnanf(posinf)) - { - Fail("_isnanf() incorrectly identified infinity as NaN!\n"); - } - - /* - * Try setting the least significant bit of the fraction, - * positive and negative - */ - UINT32 lsnan = 0xff800001u; - float snan = TO_FLOAT(lsnan); - - if (!_isnanf(snan)) - { - Fail("_isnanf() failed to identify %I32x as NaN!\n", lsnan); - } - - UINT32 lqnan = 0x7f800001u; - float qnan = TO_FLOAT(lqnan); - - if (!_isnanf(qnan)) - { - Fail("_isnanf() failed to identify %I32x as NaN!\n", lqnan); - } - - /* - * Try setting the most significant bit of the fraction, - * positive and negative - */ - lsnan = 0xffc00000u; - snan = TO_FLOAT(lsnan); - - if (!_isnanf(snan)) - { - Fail ("_isnanf() failed to identify %I32x as NaN!\n", lsnan); - } - - lqnan = 0x7fc00000u; - qnan = TO_FLOAT(lqnan); - - if (!_isnanf(qnan)) - { - Fail ("_isnanf() failed to identify %I32x as NaN!\n", lqnan); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/compilableTests.txt b/src/coreclr/pal/tests/palsuite/compilableTests.txt index 0722dfc810a705..18fb2f2510f3f6 100644 --- a/src/coreclr/pal/tests/palsuite/compilableTests.txt +++ b/src/coreclr/pal/tests/palsuite/compilableTests.txt @@ -115,8 +115,6 @@ c_runtime/wcstoul/test6/paltest_wcstoul_test6 c_runtime/_alloca/test1/paltest_alloca_test1 c_runtime/_finite/test1/paltest_finite_test1 c_runtime/_finitef/test1/paltest_finitef_test1 -c_runtime/_isnan/test1/paltest_isnan_test1 -c_runtime/_isnanf/test1/paltest_isnanf_test1 c_runtime/_itow/test1/paltest_itow_test1 c_runtime/_putenv/test1/paltest_putenv_test1 c_runtime/_putenv/test2/paltest_putenv_test2 diff --git a/src/coreclr/pal/tests/palsuite/paltestlist.txt b/src/coreclr/pal/tests/palsuite/paltestlist.txt index 60ad2f131dd37f..675bbaac83cdf9 100644 --- a/src/coreclr/pal/tests/palsuite/paltestlist.txt +++ b/src/coreclr/pal/tests/palsuite/paltestlist.txt @@ -104,8 +104,6 @@ c_runtime/wcstoul/test6/paltest_wcstoul_test6 c_runtime/_alloca/test1/paltest_alloca_test1 c_runtime/_finite/test1/paltest_finite_test1 c_runtime/_finitef/test1/paltest_finitef_test1 -c_runtime/_isnan/test1/paltest_isnan_test1 -c_runtime/_isnanf/test1/paltest_isnanf_test1 c_runtime/_itow/test1/paltest_itow_test1 c_runtime/_putenv/test1/paltest_putenv_test1 c_runtime/_putenv/test2/paltest_putenv_test2 diff --git a/src/coreclr/vm/interpreter.cpp b/src/coreclr/vm/interpreter.cpp index 5d12ee01124f41..b7c30be35743d5 100644 --- a/src/coreclr/vm/interpreter.cpp +++ b/src/coreclr/vm/interpreter.cpp @@ -6828,6 +6828,16 @@ void Interpreter::SetILInstrCategories() } #endif // INTERP_ILINSTR_PROFILE +#ifndef TARGET_WINDOWS +namespace +{ + bool isnan(float val) + { + UINT32 bits = *reinterpret_cast(&val); + return (bits & 0x7FFFFFFFU) > 0x7F800000U; + } +} +#endif template void Interpreter::CompareOp() @@ -7135,7 +7145,7 @@ INT32 Interpreter::CompareOpRes(unsigned op1idx) else if (op == CO_GT_UN) { // Check for NAN's here: if either is a NAN, they're unordered, so this comparison returns true. - if (_isnan(val1) || _isnan(val2)) res = 1; + if (isnan(val1) || isnan(val2)) res = 1; else if (val1 > val2) res = 1; } else if (op == CO_LT) @@ -7146,7 +7156,7 @@ INT32 Interpreter::CompareOpRes(unsigned op1idx) { _ASSERTE(op == CO_LT_UN); // Check for NAN's here: if either is a NAN, they're unordered, so this comparison returns true. - if (_isnan(val1) || _isnan(val2)) res = 1; + if (isnan(val1) || isnan(val2)) res = 1; else if (val1 < val2) res = 1; } } @@ -7177,7 +7187,7 @@ INT32 Interpreter::CompareOpRes(unsigned op1idx) else if (op == CO_GT_UN) { // Check for NAN's here: if either is a NAN, they're unordered, so this comparison returns true. - if (_isnan(val1) || _isnan(val2)) res = 1; + if (isnan(val1) || isnan(val2)) res = 1; else if (val1 > val2) res = 1; } else if (op == CO_LT) @@ -7188,7 +7198,7 @@ INT32 Interpreter::CompareOpRes(unsigned op1idx) { _ASSERTE(op == CO_LT_UN); // Check for NAN's here: if either is a NAN, they're unordered, so this comparison returns true. - if (_isnan(val1) || _isnan(val2)) res = 1; + if (isnan(val1) || isnan(val2)) res = 1; else if (val1 < val2) res = 1; } } diff --git a/src/coreclr/vm/jithelpers.cpp b/src/coreclr/vm/jithelpers.cpp index 6f31284615846a..13ef94710ae998 100644 --- a/src/coreclr/vm/jithelpers.cpp +++ b/src/coreclr/vm/jithelpers.cpp @@ -674,6 +674,17 @@ HCIMPL1_V(INT64, JIT_Dbl2LngOvf, double val) } HCIMPLEND +#ifndef TARGET_WINDOWS +namespace +{ + bool isnan(float val) + { + UINT32 bits = *reinterpret_cast(&val); + return (bits & 0x7FFFFFFFU) > 0x7F800000U; + } +} +#endif + HCIMPL2_VV(float, JIT_FltRem, float dividend, float divisor) { FCALL_CONTRACT; @@ -694,7 +705,7 @@ HCIMPL2_VV(float, JIT_FltRem, float dividend, float divisor) UINT32 NaN = CLR_NAN_32; return *(float *)(&NaN); } - else if (!_finite(divisor) && !_isnan(divisor)) + else if (!_finite(divisor) && !isnan(divisor)) { return dividend; } @@ -727,7 +738,7 @@ HCIMPL2_VV(double, JIT_DblRem, double dividend, double divisor) UINT64 NaN = CLR_NAN_64; return *(double *)(&NaN); } - else if (!_finite(divisor) && !_isnan(divisor)) + else if (!_finite(divisor) && !isnan(divisor)) { return dividend; } From 2c842dfd06beaddbb5f9e6d2faa5531c706d8311 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Wed, 7 Feb 2024 00:25:40 +0000 Subject: [PATCH 11/18] Remove _copysign from the PAL --- src/coreclr/jit/utils.cpp | 16 +------- src/coreclr/pal/inc/pal.h | 4 +- src/coreclr/pal/src/cruntime/math.cpp | 38 ------------------- src/coreclr/pal/src/include/pal/palinternal.h | 4 ++ src/coreclr/vm/jithelpers.cpp | 4 +- 5 files changed, 10 insertions(+), 56 deletions(-) diff --git a/src/coreclr/jit/utils.cpp b/src/coreclr/jit/utils.cpp index 6622cb64ba138a..8e75b880fa2330 100644 --- a/src/coreclr/jit/utils.cpp +++ b/src/coreclr/jit/utils.cpp @@ -2391,7 +2391,7 @@ double FloatingPointUtils::round(double x) // we need to preserve the original sign for IEEE compliance. double result = ((exponent == 0x03FE) && ((bits & UI64(0x000FFFFFFFFFFFFF)) != 0)) ? 1.0 : 0.0; - return _copysign(result, x); + return copysign(result, x); } if (exponent >= 0x0433) @@ -2434,18 +2434,6 @@ double FloatingPointUtils::round(double x) return *reinterpret_cast(&bits); } -// Windows x86 and Windows ARM/ARM64 may not define _copysignf() but they do define _copysign(). -// We will redirect the macro to this other functions if the macro is not defined for the platform. -// This has the side effect of a possible implicit upcasting for arguments passed in and an explicit -// downcasting for the _copysign() call. -#if (defined(TARGET_X86) || defined(TARGET_ARM) || defined(TARGET_ARM64)) && !defined(TARGET_UNIX) - -#if !defined(_copysignf) -#define _copysignf (float)_copysign -#endif - -#endif - // Rounds a single-precision floating-point value to the nearest integer, // and rounds midpoint values to the nearest even number. float FloatingPointUtils::round(float x) @@ -2473,7 +2461,7 @@ float FloatingPointUtils::round(float x) // we need to preserve the original sign for IEEE compliance. float result = ((exponent == 0x7E) && ((bits & 0x007FFFFF) != 0)) ? 1.0f : 0.0f; - return _copysignf(result, x); + return copysignf(result, x); } if (exponent >= 0x96) diff --git a/src/coreclr/pal/inc/pal.h b/src/coreclr/pal/inc/pal.h index 902802796fce34..ebe9d8380b4e44 100644 --- a/src/coreclr/pal/inc/pal.h +++ b/src/coreclr/pal/inc/pal.h @@ -4193,7 +4193,7 @@ PALIMPORT long long __cdecl llabs(long long); #ifndef PAL_STDCPP_COMPAT PALIMPORT int __cdecl _finite(double); -PALIMPORT double __cdecl _copysign(double, double); +PALIMPORT double __cdecl copysign(double, double); PALIMPORT double __cdecl acos(double); PALIMPORT double __cdecl acosh(double) MATH_THROW_DECL; PALIMPORT double __cdecl asin(double); @@ -4228,7 +4228,7 @@ PALIMPORT double __cdecl tanh(double); PALIMPORT double __cdecl trunc(double); PALIMPORT int __cdecl _finitef(float); -PALIMPORT float __cdecl _copysignf(float, float); +PALIMPORT float __cdecl copysignf(float, float); PALIMPORT float __cdecl acosf(float); PALIMPORT float __cdecl acoshf(float) MATH_THROW_DECL; PALIMPORT float __cdecl asinf(float); diff --git a/src/coreclr/pal/src/cruntime/math.cpp b/src/coreclr/pal/src/cruntime/math.cpp index 3fa95149123aef..bec0fa99c89b65 100644 --- a/src/coreclr/pal/src/cruntime/math.cpp +++ b/src/coreclr/pal/src/cruntime/math.cpp @@ -54,25 +54,6 @@ int __cdecl _finite(double x) return ret; } -/*++ -Function: - _copysign - -See MSDN doc ---*/ -double __cdecl _copysign(double x, double y) -{ - double ret; - PERF_ENTRY(_copysign); - ENTRY("_copysign (x=%f, y=%f)\n", x, y); - - ret = copysign(x, y); - - LOGEXIT("_copysign returns double %f\n", ret); - PERF_EXIT(_copysign); - return ret; -} - /*++ Function: _finitef @@ -102,22 +83,3 @@ int __cdecl _finitef(float x) PERF_EXIT(_finitef); return ret; } - -/*++ -Function: - _copysignf - -See MSDN doc ---*/ -float __cdecl _copysignf(float x, float y) -{ - float ret; - PERF_ENTRY(_copysignf); - ENTRY("_copysignf (x=%f, y=%f)\n", x, y); - - ret = copysign(x, y); - - LOGEXIT("_copysignf returns float %f\n", ret); - PERF_EXIT(_copysignf); - return ret; -} diff --git a/src/coreclr/pal/src/include/pal/palinternal.h b/src/coreclr/pal/src/include/pal/palinternal.h index a143b065e1177b..958ae269272ed6 100644 --- a/src/coreclr/pal/src/include/pal/palinternal.h +++ b/src/coreclr/pal/src/include/pal/palinternal.h @@ -247,6 +247,8 @@ function_name() to call the system's implementation #define log10f DUMMMY_log10f #define powf DUMMMY_powf #define sincosf DUMMMY_sincosf +#define copysign DUMMY_copysign +#define copysignf DUMMY_copysignf #define remove DUMMY_remove #define printf DUMMY_printf #define vprintf DUMMY_vprintf @@ -474,6 +476,7 @@ function_name() to call the system's implementation #undef pow #undef sin #undef sincos +#undef copysign #undef sinh #undef sqrt #undef tan @@ -503,6 +506,7 @@ function_name() to call the system's implementation #undef powf #undef sinf #undef sincosf +#undef copysignf #undef sinhf #undef sqrtf #undef tanf diff --git a/src/coreclr/vm/jithelpers.cpp b/src/coreclr/vm/jithelpers.cpp index 13ef94710ae998..d0e254b6e749ae 100644 --- a/src/coreclr/vm/jithelpers.cpp +++ b/src/coreclr/vm/jithelpers.cpp @@ -533,12 +533,12 @@ ftype BankersRound(ftype value) return integerPart; // Else return the nearest even integer - return (ftype)_copysign(ceil(fabs(value+0.5)), + return (ftype)copysign(ceil(fabs(value+0.5)), value); } // Otherwise round to closest - return (ftype)_copysign(floor(fabs(value)+0.5), + return (ftype)copysign(floor(fabs(value)+0.5), value); } From 267e6e19a91353e207b664f609e5b32fd1a222ec Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Wed, 7 Feb 2024 00:38:51 +0000 Subject: [PATCH 12/18] Remove _finite from the PAL and delete the now-empty math.cpp --- src/coreclr/jit/utils.cpp | 32 +++++ src/coreclr/jit/utils.h | 4 + src/coreclr/jit/valuenum.cpp | 14 +-- src/coreclr/pal/inc/pal.h | 2 - src/coreclr/pal/src/CMakeLists.txt | 1 - src/coreclr/pal/src/cruntime/math.cpp | 85 ------------- src/coreclr/pal/tests/palsuite/CMakeLists.txt | 2 - .../c_runtime/_finite/test1/test1.cpp | 118 ------------------ .../c_runtime/_finitef/test1/test1.cpp | 118 ------------------ .../pal/tests/palsuite/compilableTests.txt | 2 - .../pal/tests/palsuite/paltestlist.txt | 2 - src/coreclr/vm/interpreter.cpp | 2 +- src/coreclr/vm/jithelpers.cpp | 13 +- 13 files changed, 53 insertions(+), 342 deletions(-) delete mode 100644 src/coreclr/pal/src/cruntime/math.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/_finite/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/_finitef/test1/test1.cpp diff --git a/src/coreclr/jit/utils.cpp b/src/coreclr/jit/utils.cpp index 8e75b880fa2330..cd770945ef870b 100644 --- a/src/coreclr/jit/utils.cpp +++ b/src/coreclr/jit/utils.cpp @@ -2628,6 +2628,38 @@ bool FloatingPointUtils::isAllBitsSet(double val) return bits == 0xFFFFFFFFFFFFFFFFULL; } +//------------------------------------------------------------------------ +// isFinite: Determines whether the specified value is finite +// +// Arguments: +// val - value to check is not NaN or infinity +// +// Return Value: +// True if val is finite +// + +bool FloatingPointUtils::isFinite(float val) +{ + UINT32 bits = *reinterpret_cast(&val); + return (bits & 0x7FFFFFFFU) >= 0x7F800000U; +} + +//------------------------------------------------------------------------ +// isFinite: Determines whether the specified value is finite +// +// Arguments: +// val - value to check is not NaN or infinity +// +// Return Value: +// True if val is finite +// + +bool FloatingPointUtils::isFinite(double val) +{ + UINT64 bits = *reinterpret_cast(&val); + return (bits & 0x7FFFFFFFFFFFFFFFULL) >= 0x7FF0000000000000ULL; +} + //------------------------------------------------------------------------ // isNegative: Determines whether the specified value is negative // diff --git a/src/coreclr/jit/utils.h b/src/coreclr/jit/utils.h index 20de1ad103c61f..5378a08422365e 100644 --- a/src/coreclr/jit/utils.h +++ b/src/coreclr/jit/utils.h @@ -813,6 +813,10 @@ class FloatingPointUtils static bool isAllBitsSet(double val); + static bool isFinite(float val); + + static bool isFinite(double val); + static bool isNegative(float val); static bool isNegative(double val); diff --git a/src/coreclr/jit/valuenum.cpp b/src/coreclr/jit/valuenum.cpp index 8c5842cdd56f27..b170a386f9e076 100644 --- a/src/coreclr/jit/valuenum.cpp +++ b/src/coreclr/jit/valuenum.cpp @@ -101,7 +101,7 @@ TFp FpAdd(TFp value1, TFp value2) // If [value1] is positive infinity and [value2] is negative infinity // the result is NaN. - if (!_finite(value1) && !_finite(value2)) + if (!FloatingPointUtils::isFinite(value1) && !FloatingPointUtils::isFinite(value2)) { if (value1 < 0 && value2 > 0) { @@ -137,7 +137,7 @@ TFp FpSub(TFp value1, TFp value2) // If [value1] is negative infinity and [value2] is negative infinity // the result is NaN. - if (!_finite(value1) && !_finite(value2)) + if (!FloatingPointUtils::isFinite(value1) && !FloatingPointUtils::isFinite(value2)) { if (value1 > 0 && value2 > 0) { @@ -175,11 +175,11 @@ TFp FpMul(TFp value1, TFp value2) // If [value1] is infinity and [value2] is zero // the result is NaN. - if (value1 == 0 && !_finite(value2) && !FloatingPointUtils::isNaN(value2)) + if (value1 == 0 && !FloatingPointUtils::isFinite(value2) && !FloatingPointUtils::isNaN(value2)) { return TFpTraits::NaN(); } - if (!_finite(value1) && !FloatingPointUtils::isNaN(value1) && value2 == 0) + if (!FloatingPointUtils::isFinite(value1) && !FloatingPointUtils::isNaN(value1) && value2 == 0) { return TFpTraits::NaN(); } @@ -213,7 +213,7 @@ TFp FpDiv(TFp dividend, TFp divisor) { return TFpTraits::NaN(); } - else if (!_finite(dividend) && !FloatingPointUtils::isNaN(dividend) && !_finite(divisor) && !FloatingPointUtils::isNaN(divisor)) + else if (!FloatingPointUtils::isFinite(dividend) && !FloatingPointUtils::isNaN(dividend) && !FloatingPointUtils::isFinite(divisor) && !FloatingPointUtils::isNaN(divisor)) { return TFpTraits::NaN(); } @@ -232,11 +232,11 @@ TFp FpRem(TFp dividend, TFp divisor) // If [divisor] is infinity, // the result is [dividend] - if (divisor == 0 || !_finite(dividend)) + if (divisor == 0 || !FloatingPointUtils::isFinite(dividend)) { return TFpTraits::NaN(); } - else if (!_finite(divisor) && !FloatingPointUtils::isNaN(divisor)) + else if (!FloatingPointUtils::isFinite(divisor) && !FloatingPointUtils::isNaN(divisor)) { return dividend; } diff --git a/src/coreclr/pal/inc/pal.h b/src/coreclr/pal/inc/pal.h index ebe9d8380b4e44..6cb4da2a4dca60 100644 --- a/src/coreclr/pal/inc/pal.h +++ b/src/coreclr/pal/inc/pal.h @@ -4192,7 +4192,6 @@ PALIMPORT int __cdecl abs(int); PALIMPORT long long __cdecl llabs(long long); #ifndef PAL_STDCPP_COMPAT -PALIMPORT int __cdecl _finite(double); PALIMPORT double __cdecl copysign(double, double); PALIMPORT double __cdecl acos(double); PALIMPORT double __cdecl acosh(double) MATH_THROW_DECL; @@ -4227,7 +4226,6 @@ PALIMPORT double __cdecl tan(double); PALIMPORT double __cdecl tanh(double); PALIMPORT double __cdecl trunc(double); -PALIMPORT int __cdecl _finitef(float); PALIMPORT float __cdecl copysignf(float, float); PALIMPORT float __cdecl acosf(float); PALIMPORT float __cdecl acoshf(float) MATH_THROW_DECL; diff --git a/src/coreclr/pal/src/CMakeLists.txt b/src/coreclr/pal/src/CMakeLists.txt index aa7e8d9dd023dc..24f07139591779 100644 --- a/src/coreclr/pal/src/CMakeLists.txt +++ b/src/coreclr/pal/src/CMakeLists.txt @@ -132,7 +132,6 @@ set(SOURCES cruntime/file.cpp cruntime/filecrt.cpp cruntime/malloc.cpp - cruntime/math.cpp cruntime/misc.cpp cruntime/printfcpp.cpp cruntime/string.cpp diff --git a/src/coreclr/pal/src/cruntime/math.cpp b/src/coreclr/pal/src/cruntime/math.cpp deleted file mode 100644 index bec0fa99c89b65..00000000000000 --- a/src/coreclr/pal/src/cruntime/math.cpp +++ /dev/null @@ -1,85 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*++ - - - -Module Name: - - math.cpp - -Abstract: - - Implementation of math family functions. - - - ---*/ - -#include "pal/palinternal.h" -#include "pal/dbgmsg.h" - -#include - -SET_DEFAULT_DEBUG_CHANNEL(CRT); - -/*++ -Function: - _finite - -Determines whether given double-precision floating point value is finite. - -Return Value - -_finite returns a nonzero value (TRUE) if its argument x is not -infinite, that is, if -INF < x < +INF. It returns 0 (FALSE) if the -argument is infinite or a NaN. - -Parameter - -x Double-precision floating-point value - ---*/ -int __cdecl _finite(double x) -{ - int ret; - PERF_ENTRY(_finite); - ENTRY("_finite (x=%f)\n", x); - - ret = isfinite(x); - - LOGEXIT("_finite returns int %d\n", ret); - PERF_EXIT(_finite); - return ret; -} - -/*++ -Function: - _finitef - -Determines whether given single-precision floating point value is finite. - -Return Value - -_finitef returns a nonzero value (TRUE) if its argument x is not -infinite, that is, if -INF < x < +INF. It returns 0 (FALSE) if the -argument is infinite or a NaN. - -Parameter - -x Single-precision floating-point value - ---*/ -int __cdecl _finitef(float x) -{ - int ret; - PERF_ENTRY(_finitef); - ENTRY("_finitef (x=%f)\n", x); - - ret = isfinite(x); - - LOGEXIT("_finitef returns int %d\n", ret); - PERF_EXIT(_finitef); - return ret; -} diff --git a/src/coreclr/pal/tests/palsuite/CMakeLists.txt b/src/coreclr/pal/tests/palsuite/CMakeLists.txt index 8f9cd295621154..50352184bc1a77 100644 --- a/src/coreclr/pal/tests/palsuite/CMakeLists.txt +++ b/src/coreclr/pal/tests/palsuite/CMakeLists.txt @@ -171,8 +171,6 @@ add_executable_clr(paltests c_runtime/wcstoul/test5/test5.cpp c_runtime/wcstoul/test6/test6.cpp c_runtime/_alloca/test1/test1.cpp - c_runtime/_finite/test1/test1.cpp - c_runtime/_finitef/test1/test1.cpp #c_runtime/_gcvt/test1/_gcvt.cpp #c_runtime/_gcvt/test2/test2.cpp c_runtime/_itow/test1/test1.cpp diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/_finite/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/_finite/test1/test1.cpp deleted file mode 100644 index e21c9551b5c0a9..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/_finite/test1/test1.cpp +++ /dev/null @@ -1,118 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Checks that _finite correctly classifies all types -** of floating point numbers (NaN, -Infinity, Infinity, -** finite nonzero, unnormalized, 0, and -0) -** -**==========================================================================*/ - -#include - -/* -The IEEE double precision floating point standard looks like this: - - S EEEEEEEEEEE FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF - 0 1 11 12 63 - -S is the sign bit. The E bits are the exponent, and the 52 F bits are -the fraction. These represent a value, V. - -If E=2047 and F is nonzero, then V=NaN ("Not a number") -If E=2047 and F is zero and S is 1, then V=-Infinity -If E=2047 and F is zero and S is 0, then V=Infinity -If 0 - -/* -The IEEE single precision floating point standard looks like this: - - S EEEEEEEE FFFFFFFFFFFFFFFFFFFFFFF - 0 1 8 9 31 - -S is the sign bit. The E bits are the exponent, and the 23 F bits are -the fraction. These represent a value, V. - -If E=255 and F is nonzero, then V=NaN ("Not a number") -If E=255 and F is zero and S is 1, then V=-Infinity -If E=255 and F is zero and S is 0, then V=Infinity -If 0(&val); return (bits & 0x7FFFFFFFU) > 0x7F800000U; } + bool isfinite(float val) + { + UINT32 bits = *reinterpret_cast(&val); + return (bits & 0x7FFFFFFFU) >= 0x7F800000U; + } } #endif @@ -700,12 +705,12 @@ HCIMPL2_VV(float, JIT_FltRem, float dividend, float divisor) // ***"negated for -infinity" has been removed from the spec // - if (divisor==0 || !_finite(dividend)) + if (divisor==0 || !isfinite(dividend)) { UINT32 NaN = CLR_NAN_32; return *(float *)(&NaN); } - else if (!_finite(divisor) && !isnan(divisor)) + else if (!isfinite(divisor) && !isnan(divisor)) { return dividend; } @@ -733,12 +738,12 @@ HCIMPL2_VV(double, JIT_DblRem, double dividend, double divisor) // // ***"negated for -infinity" has been removed from the spec // - if (divisor==0 || !_finite(dividend)) + if (divisor==0 || !isfinite(dividend)) { UINT64 NaN = CLR_NAN_64; return *(double *)(&NaN); } - else if (!_finite(divisor) && !isnan(divisor)) + else if (!isfinite(divisor) && !isnan(divisor)) { return dividend; } From c7a561f4e0afd96c689468df8e0d8d66f4b2c4c5 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Wed, 7 Feb 2024 17:15:49 +0000 Subject: [PATCH 13/18] Fix isfinite implementation --- src/coreclr/jit/utils.cpp | 4 ++-- src/coreclr/vm/jithelpers.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/coreclr/jit/utils.cpp b/src/coreclr/jit/utils.cpp index cd770945ef870b..aa9baa7a70e7e1 100644 --- a/src/coreclr/jit/utils.cpp +++ b/src/coreclr/jit/utils.cpp @@ -2641,7 +2641,7 @@ bool FloatingPointUtils::isAllBitsSet(double val) bool FloatingPointUtils::isFinite(float val) { UINT32 bits = *reinterpret_cast(&val); - return (bits & 0x7FFFFFFFU) >= 0x7F800000U; + return (bits & 0x7FFFFFFFU) < 0x7F800000U; } //------------------------------------------------------------------------ @@ -2657,7 +2657,7 @@ bool FloatingPointUtils::isFinite(float val) bool FloatingPointUtils::isFinite(double val) { UINT64 bits = *reinterpret_cast(&val); - return (bits & 0x7FFFFFFFFFFFFFFFULL) >= 0x7FF0000000000000ULL; + return (bits & 0x7FFFFFFFFFFFFFFFULL) < 0x7FF0000000000000ULL; } //------------------------------------------------------------------------ diff --git a/src/coreclr/vm/jithelpers.cpp b/src/coreclr/vm/jithelpers.cpp index 05e9b1e121bf8a..cf8271a694d79b 100644 --- a/src/coreclr/vm/jithelpers.cpp +++ b/src/coreclr/vm/jithelpers.cpp @@ -685,7 +685,7 @@ namespace bool isfinite(float val) { UINT32 bits = *reinterpret_cast(&val); - return (bits & 0x7FFFFFFFU) >= 0x7F800000U; + return (bits & 0x7FFFFFFFU) < 0x7F800000U; } } #endif From 6f5f5245f532579a9ccda10adbd19583286a149a Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Wed, 7 Feb 2024 18:04:06 +0000 Subject: [PATCH 14/18] Revert changes to Mono --- src/mono/mono/mini/CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/mono/mono/mini/CMakeLists.txt b/src/mono/mono/mini/CMakeLists.txt index c5b6596e7e5624..5e6ebe9ce49dc4 100644 --- a/src/mono/mono/mini/CMakeLists.txt +++ b/src/mono/mono/mini/CMakeLists.txt @@ -337,7 +337,6 @@ endif() if(ENABLE_INTERP_LIB) add_library(mono-ee-interp STATIC "${interp_sources}") target_link_libraries(mono-ee-interp PRIVATE monoapi eglib_api) -target_link_libraries(mono-ee-interp PUBLIC) target_include_directories(mono-ee-interp PRIVATE ${PROJECT_BINARY_DIR}/../.. ${PROJECT_SOURCE_DIR}/../.. ${PROJECT_SOURCE_DIR}/..) @@ -406,7 +405,6 @@ endif() add_library(monosgen-static STATIC $ $ $ $ $) set_target_properties(monosgen-static PROPERTIES OUTPUT_NAME ${MONO_LIB_NAME}) -target_link_libraries(monosgen-static PUBLIC) if(DISABLE_COMPONENTS OR AOT_COMPONENTS) # add component fallback stubs into static mono library when components have been disabled. From 6ffc62b8722f0431a717158ae062d4ce6bbf8a53 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 8 Feb 2024 11:31:03 -0800 Subject: [PATCH 15/18] Change the native isFinite implementation to use the same implementation as managed code --- src/coreclr/jit/utils.cpp | 4 ++-- src/coreclr/vm/jithelpers.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/coreclr/jit/utils.cpp b/src/coreclr/jit/utils.cpp index 40050fd2fa393c..619482dd6bc987 100644 --- a/src/coreclr/jit/utils.cpp +++ b/src/coreclr/jit/utils.cpp @@ -2585,7 +2585,7 @@ bool FloatingPointUtils::isAllBitsSet(double val) bool FloatingPointUtils::isFinite(float val) { UINT32 bits = *reinterpret_cast(&val); - return (bits & 0x7FFFFFFFU) < 0x7F800000U; + return (~bits & 0x7F800000U) != 0; } //------------------------------------------------------------------------ @@ -2601,7 +2601,7 @@ bool FloatingPointUtils::isFinite(float val) bool FloatingPointUtils::isFinite(double val) { UINT64 bits = *reinterpret_cast(&val); - return (bits & 0x7FFFFFFFFFFFFFFFULL) < 0x7FF0000000000000ULL; + return (~bits & 0x7FF0000000000000ULL) != 0; } //------------------------------------------------------------------------ diff --git a/src/coreclr/vm/jithelpers.cpp b/src/coreclr/vm/jithelpers.cpp index cf8271a694d79b..06384a5617a70f 100644 --- a/src/coreclr/vm/jithelpers.cpp +++ b/src/coreclr/vm/jithelpers.cpp @@ -685,7 +685,7 @@ namespace bool isfinite(float val) { UINT32 bits = *reinterpret_cast(&val); - return (bits & 0x7FFFFFFFU) < 0x7F800000U; + return (~bits & 0x7F800000U) != 0; } } #endif From 34adfb146a57ce40c7a68870a4f7a5abfba71fa0 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Fri, 9 Feb 2024 11:55:52 -0800 Subject: [PATCH 16/18] Apparently we don't have the PAL/standard overloads available here. Define the double overloads. --- src/coreclr/vm/jithelpers.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/coreclr/vm/jithelpers.cpp b/src/coreclr/vm/jithelpers.cpp index 06384a5617a70f..4960474cff244b 100644 --- a/src/coreclr/vm/jithelpers.cpp +++ b/src/coreclr/vm/jithelpers.cpp @@ -682,11 +682,21 @@ namespace UINT32 bits = *reinterpret_cast(&val); return (bits & 0x7FFFFFFFU) > 0x7F800000U; } + bool isnan(double val) + { + UINT64 bits = *reinterpret_cast(&val); + return (bits & 0x7FFFFFFFFFFFFFFFULL) > 0x7FF0000000000000ULL; + } bool isfinite(float val) { UINT32 bits = *reinterpret_cast(&val); return (~bits & 0x7F800000U) != 0; } + bool isfinite(double val) + { + UINT64 bits = *reinterpret_cast(&val); + return (~bits & 0x7FF0000000000000ULL) != 0; + } } #endif From 92bb263c5262b6e84ecea65b011f72257b0965d3 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Fri, 9 Feb 2024 13:32:41 -0800 Subject: [PATCH 17/18] Fix formatting --- src/coreclr/jit/valuenum.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/coreclr/jit/valuenum.cpp b/src/coreclr/jit/valuenum.cpp index 692f23014614e5..3c93df5a0065e2 100644 --- a/src/coreclr/jit/valuenum.cpp +++ b/src/coreclr/jit/valuenum.cpp @@ -213,7 +213,8 @@ TFp FpDiv(TFp dividend, TFp divisor) { return TFpTraits::NaN(); } - else if (!FloatingPointUtils::isFinite(dividend) && !FloatingPointUtils::isNaN(dividend) && !FloatingPointUtils::isFinite(divisor) && !FloatingPointUtils::isNaN(divisor)) + else if (!FloatingPointUtils::isFinite(dividend) && !FloatingPointUtils::isNaN(dividend) && + !FloatingPointUtils::isFinite(divisor) && !FloatingPointUtils::isNaN(divisor)) { return TFpTraits::NaN(); } From 1b39abb05023370ba18cbfb4607e36526bdea359 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Sat, 10 Feb 2024 03:53:26 +0000 Subject: [PATCH 18/18] Remove now-unneceesary tryrun.cmake statements --- eng/native/tryrun.cmake | 31 ------------------------------- eng/native/tryrun_ios_tvos.cmake | 11 ----------- 2 files changed, 42 deletions(-) diff --git a/eng/native/tryrun.cmake b/eng/native/tryrun.cmake index a239af9fc937f0..a4cc7eaf93106f 100644 --- a/eng/native/tryrun.cmake +++ b/eng/native/tryrun.cmake @@ -58,15 +58,6 @@ if(DARWIN) set_cache_value(HAVE_CLOCK_REALTIME_EXITCODE 0) set_cache_value(HAVE_CLOCK_THREAD_CPUTIME_EXITCODE 0) set_cache_value(HAVE_CLOCK_GETTIME_NSEC_NP_EXITCODE 0) - set_cache_value(HAVE_COMPATIBLE_ACOS_EXITCODE 0) - set_cache_value(HAVE_COMPATIBLE_ASIN_EXITCODE 0) - set_cache_value(HAVE_COMPATIBLE_ATAN2_EXITCODE 0) - set_cache_value(HAVE_COMPATIBLE_EXP_EXITCODE 1) - set_cache_value(HAVE_COMPATIBLE_ILOGB0_EXITCODE 0) - set_cache_value(HAVE_COMPATIBLE_ILOGBNAN_EXITCODE 1) - set_cache_value(HAVE_COMPATIBLE_LOG10_EXITCODE 0) - set_cache_value(HAVE_COMPATIBLE_LOG_EXITCODE 0) - set_cache_value(HAVE_COMPATIBLE_POW_EXITCODE 0) set_cache_value(HAVE_FUNCTIONAL_PTHREAD_ROBUST_MUTEXES_EXITCODE 1) set_cache_value(HAVE_LARGE_SNPRINTF_SUPPORT_EXITCODE 0) set_cache_value(HAVE_MMAP_DEV_ZERO_EXITCODE 1) @@ -75,8 +66,6 @@ if(DARWIN) set_cache_value(HAVE_PROCFS_STATM_EXITCODE 1) set_cache_value(HAVE_SCHED_GETCPU_EXITCODE 1) set_cache_value(HAVE_SCHED_GET_PRIORITY_EXITCODE 0) - set_cache_value(HAVE_VALID_NEGATIVE_INF_POW_EXITCODE 0) - set_cache_value(HAVE_VALID_POSITIVE_INF_POW_EXITCODE 0) set_cache_value(HAVE_WORKING_CLOCK_GETTIME_EXITCODE 0) set_cache_value(HAVE_WORKING_GETTIMEOFDAY_EXITCODE 0) set_cache_value(MMAP_ANON_IGNORES_PROTECTION_EXITCODE 1) @@ -97,14 +86,6 @@ elseif(TARGET_ARCH_NAME MATCHES "^(armel|arm|armv6|arm64|loongarch64|riscv64|s39 set_cache_value(HAVE_CLOCK_MONOTONIC_EXITCODE 0) set_cache_value(HAVE_CLOCK_REALTIME_EXITCODE 0) set_cache_value(HAVE_CLOCK_THREAD_CPUTIME_EXITCODE 0) - set_cache_value(HAVE_COMPATIBLE_ACOS_EXITCODE 0) - set_cache_value(HAVE_COMPATIBLE_ASIN_EXITCODE 0) - set_cache_value(HAVE_COMPATIBLE_ATAN2_EXITCODE 0) - set_cache_value(HAVE_COMPATIBLE_ILOGB0_EXITCODE 1) - set_cache_value(HAVE_COMPATIBLE_ILOGBNAN_EXITCODE 1) - set_cache_value(HAVE_COMPATIBLE_LOG10_EXITCODE 0) - set_cache_value(HAVE_COMPATIBLE_LOG_EXITCODE 0) - set_cache_value(HAVE_COMPATIBLE_POW_EXITCODE 0) set_cache_value(HAVE_LARGE_SNPRINTF_SUPPORT_EXITCODE 0) set_cache_value(HAVE_MMAP_DEV_ZERO_EXITCODE 0) set_cache_value(HAVE_PROCFS_CTL_EXITCODE 1) @@ -112,8 +93,6 @@ elseif(TARGET_ARCH_NAME MATCHES "^(armel|arm|armv6|arm64|loongarch64|riscv64|s39 set_cache_value(HAVE_PROCFS_STATM_EXITCODE 0) set_cache_value(HAVE_SCHED_GETCPU_EXITCODE 0) set_cache_value(HAVE_SCHED_GET_PRIORITY_EXITCODE 0) - set_cache_value(HAVE_VALID_NEGATIVE_INF_POW_EXITCODE 0) - set_cache_value(HAVE_VALID_POSITIVE_INF_POW_EXITCODE 0) set_cache_value(HAVE_WORKING_CLOCK_GETTIME_EXITCODE 0) set_cache_value(HAVE_WORKING_GETTIMEOFDAY_EXITCODE 0) set_cache_value(ONE_SHARED_MAPPING_PER_FILEREGION_PER_PROCESS_EXITCODE 1) @@ -140,16 +119,8 @@ elseif(TARGET_ARCH_NAME MATCHES "^(armel|arm|armv6|arm64|loongarch64|riscv64|s39 set_cache_value(HAVE_PROCFS_STAT 0) set_cache_value(HAVE_PROCFS_STATM 0) set_cache_value(UNGETC_NOT_RETURN_EOF 0) - set_cache_value(HAVE_COMPATIBLE_ILOGBNAN 1) set_cache_value(HAVE_FUNCTIONAL_PTHREAD_ROBUST_MUTEXES_EXITCODE 0) elseif(ILLUMOS) - set_cache_value(HAVE_COMPATIBLE_ACOS_EXITCODE 1) - set_cache_value(HAVE_COMPATIBLE_ASIN_EXITCODE 1) - set_cache_value(HAVE_COMPATIBLE_ATAN2_EXITCODE 1) - set_cache_value(HAVE_COMPATIBLE_POW_EXITCODE 1) - set_cache_value(HAVE_COMPATIBLE_ILOGBNAN_EXITCODE 0) - set_cache_value(HAVE_COMPATIBLE_LOG10_EXITCODE 1) - set_cache_value(HAVE_COMPATIBLE_LOG_EXITCODE 1) set_cache_value(HAVE_LARGE_SNPRINTF_SUPPORT_EXITCODE 1) set_cache_value(HAVE_PROCFS_CTL_EXITCODE 0) set_cache_value(SSCANF_SUPPORT_ll_EXITCODE 1) @@ -162,8 +133,6 @@ elseif(TARGET_ARCH_NAME MATCHES "^(armel|arm|armv6|arm64|loongarch64|riscv64|s39 set_cache_value(HAVE_FUNCTIONAL_PTHREAD_ROBUST_MUTEXES_EXITCODE 0) elseif(HAIKU) set_cache_value(HAVE_CLOCK_MONOTONIC_COARSE_EXITCODE 1) - set_cache_value(HAVE_COMPATIBLE_EXP_EXITCODE 0) - set_cache_value(HAVE_COMPATIBLE_ILOGBNAN_EXITCODE 0) set_cache_value(HAVE_PROCFS_STAT_EXITCODE 1) set_cache_value(HAVE_PROCFS_STATM_EXITCODE 1) endif() diff --git a/eng/native/tryrun_ios_tvos.cmake b/eng/native/tryrun_ios_tvos.cmake index 790c802c30ac57..e3dfeb62780b30 100644 --- a/eng/native/tryrun_ios_tvos.cmake +++ b/eng/native/tryrun_ios_tvos.cmake @@ -17,15 +17,6 @@ set_cache_value(HAVE_BROKEN_FIFO_SELECT_EXITCODE 1) set_cache_value(HAVE_CLOCK_REALTIME_EXITCODE 0) set_cache_value(HAVE_CLOCK_THREAD_CPUTIME_EXITCODE 0) set_cache_value(HAVE_CLOCK_GETTIME_NSEC_NP_EXITCODE 0) -set_cache_value(HAVE_COMPATIBLE_ACOS_EXITCODE 0) -set_cache_value(HAVE_COMPATIBLE_ASIN_EXITCODE 0) -set_cache_value(HAVE_COMPATIBLE_ATAN2_EXITCODE 0) -set_cache_value(HAVE_COMPATIBLE_EXP_EXITCODE 1) -set_cache_value(HAVE_COMPATIBLE_ILOGB0_EXITCODE 0) -set_cache_value(HAVE_COMPATIBLE_ILOGBNAN_EXITCODE 1) -set_cache_value(HAVE_COMPATIBLE_LOG10_EXITCODE 0) -set_cache_value(HAVE_COMPATIBLE_LOG_EXITCODE 0) -set_cache_value(HAVE_COMPATIBLE_POW_EXITCODE 0) set_cache_value(HAVE_FUNCTIONAL_PTHREAD_ROBUST_MUTEXES_EXITCODE 1) set_cache_value(HAVE_LARGE_SNPRINTF_SUPPORT_EXITCODE 0) set_cache_value(HAVE_MMAP_DEV_ZERO_EXITCODE 1) @@ -33,8 +24,6 @@ set_cache_value(HAVE_PROCFS_CTL_EXITCODE 1) set_cache_value(HAVE_PROCFS_STAT_EXITCODE 1) set_cache_value(HAVE_PROCFS_STATM_EXITCODE 1) set_cache_value(HAVE_SCHED_GET_PRIORITY_EXITCODE 0) -set_cache_value(HAVE_VALID_NEGATIVE_INF_POW_EXITCODE 0) -set_cache_value(HAVE_VALID_POSITIVE_INF_POW_EXITCODE 0) set_cache_value(HAVE_WORKING_CLOCK_GETTIME_EXITCODE 0) set_cache_value(HAVE_WORKING_GETTIMEOFDAY_EXITCODE 0) set_cache_value(MMAP_ANON_IGNORES_PROTECTION_EXITCODE 1)