diff options
26 files changed, 354 insertions, 82 deletions
diff --git a/cross/android/arm/tryrun.cmake b/cross/android/arm/tryrun.cmake index bcc2cd202c..69b7158b4e 100644 --- a/cross/android/arm/tryrun.cmake +++ b/cross/android/arm/tryrun.cmake @@ -6,6 +6,14 @@ SET( HAVE_COMPATIBLE_EXP_EXITCODE 1 CACHE STRING "Result from TRY_RUN" FORCE) +SET( HAVE_COMPATIBLE_ILOGB0_EXITCODE + 0 + CACHE STRING "Result from TRY_RUN" FORCE) + +SET( HAVE_COMPATIBLE_ILOGBNAN_EXITCODE + 0 + CACHE STRING "Result from TRY_RUN" FORCE) + SET( REALPATH_SUPPORTS_NONEXISTENT_FILES_EXITCODE 1 CACHE STRING "Result from TRY_RUN" FORCE) diff --git a/cross/android/arm64/tryrun.cmake b/cross/android/arm64/tryrun.cmake index f32065a3bc..93a225009d 100644 --- a/cross/android/arm64/tryrun.cmake +++ b/cross/android/arm64/tryrun.cmake @@ -2,6 +2,14 @@ SET( HAVE_COMPATIBLE_EXP_EXITCODE 1 CACHE STRING "Result from TRY_RUN" FORCE) +SET( HAVE_COMPATIBLE_ILOGB0_EXITCODE + 0 + CACHE STRING "Result from TRY_RUN" FORCE) + +SET( HAVE_COMPATIBLE_ILOGBNAN_EXITCODE + 0 + CACHE STRING "Result from TRY_RUN" FORCE) + SET( REALPATH_SUPPORTS_NONEXISTENT_FILES_EXITCODE 1 CACHE STRING "Result from TRY_RUN" FORCE) diff --git a/cross/tryrun.cmake b/cross/tryrun.cmake index d0bd77dc97..47aa7b4ba7 100644 --- a/cross/tryrun.cmake +++ b/cross/tryrun.cmake @@ -23,6 +23,8 @@ if(TARGET_ARCH_NAME MATCHES "^(armel|arm|arm64|x86)$") 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 0) + set_cache_value(HAVE_COMPATIBLE_ILOGBNAN_EXITCODE 0) set_cache_value(HAVE_COMPATIBLE_LOG10_EXITCODE 0) set_cache_value(HAVE_COMPATIBLE_LOG_EXITCODE 0) set_cache_value(HAVE_COMPATIBLE_POW_EXITCODE 0) diff --git a/src/System.Private.CoreLib/shared/System/Math.cs b/src/System.Private.CoreLib/shared/System/Math.cs index 41a0806aaa..e278486775 100644 --- a/src/System.Private.CoreLib/shared/System/Math.cs +++ b/src/System.Private.CoreLib/shared/System/Math.cs @@ -538,17 +538,31 @@ namespace System public static double Max(double val1, double val2) { - if (val1 > val2) + // When val1 and val2 are both finite or infinite, return the larger + // * We count +0.0 as larger than -0.0 to match MSVC + // When val1 or val2, but not both, are NaN return the opposite + // * We return the opposite if either is NaN to match MSVC + + if (double.IsNaN(val1)) { - return val1; + return val2; } - if (double.IsNaN(val1)) + if (double.IsNaN(val2)) { return val1; } - return val2; + // We do this comparison first and separately to handle the -0.0 to +0.0 comparision + // * Doing (val1 < val2) first could get transformed into (val2 >= val1) by the JIT + // which would then return an incorrect value + + if (val1 == val2) + { + return double.IsNegative(val1) ? val2 : val1; + } + + return (val1 < val2) ? val2 : val1; } [NonVersionable] @@ -578,17 +592,31 @@ namespace System public static float Max(float val1, float val2) { - if (val1 > val2) + // When val1 and val2 are both finite or infinite, return the larger + // * We count +0.0 as larger than -0.0 to match MSVC + // When val1 or val2, but not both, are NaN return the opposite + // * We return the opposite if either is NaN to match MSVC + + if (float.IsNaN(val1)) { - return val1; + return val2; } - if (float.IsNaN(val1)) + if (float.IsNaN(val2)) { return val1; } - return val2; + // We do this comparison first and separately to handle the -0.0 to +0.0 comparision + // * Doing (val1 < val2) first could get transformed into (val2 >= val1) by the JIT + // which would then return an incorrect value + + if (val1 == val2) + { + return float.IsNegative(val1) ? val2 : val1; + } + + return (val1 < val2) ? val2 : val1; } [CLSCompliant(false)] @@ -614,7 +642,31 @@ namespace System public static double MaxMagnitude(double x, double y) { - return Max(Abs(x), Abs(y)); + // When x and y are both finite or infinite, return the larger magnitude + // * We count +0.0 as larger than -0.0 to match MSVC + // When x or y, but not both, are NaN return the opposite + // * We return the opposite if either is NaN to match MSVC + + if (double.IsNaN(x)) + { + return y; + } + + if (double.IsNaN(y)) + { + return x; + } + + // We do this comparison first and separately to handle the -0.0 to +0.0 comparision + // * Doing (x < y) first could get transformed into (y >= x) by the JIT which would + // then return an incorrect value + + if (x == y) + { + return double.IsNegative(x) ? y : x; + } + + return (Abs(x) < Abs(y)) ? y : x; } [NonVersionable] @@ -631,17 +683,31 @@ namespace System public static double Min(double val1, double val2) { - if (val1 < val2) + // When val1 and val2 are both finite or infinite, return the smaller + // * We count -0.0 as smaller than -0.0 to match MSVC + // When val1 or val2, but not both, are NaN return the opposite + // * We return the opposite if either is NaN to match MSVC + + if (double.IsNaN(val1)) { - return val1; + return val2; } - if (double.IsNaN(val1)) + if (double.IsNaN(val2)) { return val1; } - return val2; + // We do this comparison first and separately to handle the -0.0 to +0.0 comparision + // * Doing (val1 < val2) first could get transformed into (val2 >= val1) by the JIT + // which would then return an incorrect value + + if (val1 == val2) + { + return double.IsNegative(val1) ? val1 : val2; + } + + return (val1 < val2) ? val1 : val2; } [NonVersionable] @@ -671,17 +737,31 @@ namespace System public static float Min(float val1, float val2) { - if (val1 < val2) + // When val1 and val2 are both finite or infinite, return the smaller + // * We count -0.0 as smaller than -0.0 to match MSVC + // When val1 or val2, but not both, are NaN return the opposite + // * We return the opposite if either is NaN to match MSVC + + if (float.IsNaN(val1)) { - return val1; + return val2; } - if (float.IsNaN(val1)) + if (float.IsNaN(val2)) { return val1; } - return val2; + // We do this comparison first and separately to handle the -0.0 to +0.0 comparision + // * Doing (val1 < val2) first could get transformed into (val2 >= val1) by the JIT + // which would then return an incorrect value + + if (val1 == val2) + { + return float.IsNegative(val1) ? val1 : val2; + } + + return (val1 < val2) ? val1 : val2; } [CLSCompliant(false)] @@ -707,7 +787,31 @@ namespace System public static double MinMagnitude(double x, double y) { - return Min(Abs(x), Abs(y)); + // When x and y are both finite or infinite, return the smaller magnitude + // * We count -0.0 as smaller than -0.0 to match MSVC + // When x or y, but not both, are NaN return the opposite + // * We return the opposite if either is NaN to match MSVC + + if (double.IsNaN(x)) + { + return y; + } + + if (double.IsNaN(y)) + { + return x; + } + + // We do this comparison first and separately to handle the -0.0 to +0.0 comparision + // * Doing (x < y) first could get transformed into (y >= x) by the JIT which would + // then return an incorrect value + + if (x == y) + { + return double.IsNegative(x) ? x : y; + } + + return (Abs(x) < Abs(y)) ? x : y; } [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/System.Private.CoreLib/shared/System/MathF.cs b/src/System.Private.CoreLib/shared/System/MathF.cs index 9eac890d1f..428f9f88be 100644 --- a/src/System.Private.CoreLib/shared/System/MathF.cs +++ b/src/System.Private.CoreLib/shared/System/MathF.cs @@ -190,7 +190,31 @@ namespace System public static float MaxMagnitude(float x, float y) { - return Max(Abs(x), Abs(y)); + // When x and y are both finite or infinite, return the larger magnitude + // * We count +0.0 as larger than -0.0 to match MSVC + // When x or y, but not both, are NaN return the opposite + // * We return the opposite if either is NaN to match MSVC + + if (float.IsNaN(x)) + { + return y; + } + + if (float.IsNaN(y)) + { + return x; + } + + // We do this comparison first and separately to handle the -0.0 to +0.0 comparision + // * Doing (x < y) first could get transformed into (y >= x) by the JIT which would + // then return an incorrect value + + if (x == y) + { + return float.IsNegative(x) ? y : x; + } + + return (Abs(x) < Abs(y)) ? y : x; } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -201,7 +225,31 @@ namespace System public static float MinMagnitude(float x, float y) { - return Min(Abs(x), Abs(y)); + // When x and y are both finite or infinite, return the smaller magnitude + // * We count -0.0 as smaller than -0.0 to match MSVC + // When x or y, but not both, are NaN return the opposite + // * We return the opposite if either is NaN to match MSVC + + if (float.IsNaN(x)) + { + return y; + } + + if (float.IsNaN(y)) + { + return x; + } + + // We do this comparison first and separately to handle the -0.0 to +0.0 comparision + // * Doing (x < y) first could get transformed into (y >= x) by the JIT which would + // then return an incorrect value + + if (x == y) + { + return float.IsNegative(x) ? x : y; + } + + return (Abs(x) < Abs(y)) ? x : y; } [Intrinsic] diff --git a/src/System.Private.CoreLib/src/System/Math.CoreCLR.cs b/src/System.Private.CoreLib/src/System/Math.CoreCLR.cs index 5331353c19..0378bcbe0c 100644 --- a/src/System.Private.CoreLib/src/System/Math.CoreCLR.cs +++ b/src/System.Private.CoreLib/src/System/Math.CoreCLR.cs @@ -68,7 +68,7 @@ namespace System public static extern double FusedMultiplyAdd(double x, double y, double z); [MethodImpl(MethodImplOptions.InternalCall)] - public static extern int IlogB(double x); + public static extern int ILogB(double x); [MethodImpl(MethodImplOptions.InternalCall)] public static extern double Log(double d); diff --git a/src/System.Private.CoreLib/src/System/MathF.CoreCLR.cs b/src/System.Private.CoreLib/src/System/MathF.CoreCLR.cs index fa99f1f635..fb04fcd6a1 100644 --- a/src/System.Private.CoreLib/src/System/MathF.CoreCLR.cs +++ b/src/System.Private.CoreLib/src/System/MathF.CoreCLR.cs @@ -59,7 +59,7 @@ namespace System public static extern float FusedMultiplyAdd(float x, float y, float z); [MethodImpl(MethodImplOptions.InternalCall)] - public static extern int IlogB(float x); + public static extern int ILogB(float x); [MethodImpl(MethodImplOptions.InternalCall)] public static extern float Log(float x); diff --git a/src/classlibnative/float/floatdouble.cpp b/src/classlibnative/float/floatdouble.cpp index 2e4b382460..e0d0fd95e6 100644 --- a/src/classlibnative/float/floatdouble.cpp +++ b/src/classlibnative/float/floatdouble.cpp @@ -212,7 +212,7 @@ FCIMPLEND /*=====================================Ilog2==================================== ** ==============================================================================*/ -FCIMPL1_V(int, COMDouble::IlogB, double x) +FCIMPL1_V(int, COMDouble::ILogB, double x) FCALL_CONTRACT; return (int)ilogb(x); diff --git a/src/classlibnative/float/floatsingle.cpp b/src/classlibnative/float/floatsingle.cpp index 23c1445e43..39b9fd6b6f 100644 --- a/src/classlibnative/float/floatsingle.cpp +++ b/src/classlibnative/float/floatsingle.cpp @@ -199,7 +199,7 @@ FCIMPLEND /*=====================================Ilog2==================================== ** ==============================================================================*/ -FCIMPL1_V(int, COMSingle::IlogB, float x) +FCIMPL1_V(int, COMSingle::ILogB, float x) FCALL_CONTRACT; return (int)ilogbf(x); diff --git a/src/classlibnative/inc/floatdouble.h b/src/classlibnative/inc/floatdouble.h index 602b45b2f8..40d5e2ee8a 100644 --- a/src/classlibnative/inc/floatdouble.h +++ b/src/classlibnative/inc/floatdouble.h @@ -26,7 +26,7 @@ public: FCDECL1_V(static double, Floor, double x); FCDECL2_VV(static double, FMod, double x, double y); FCDECL3_VVV(static double, FusedMultiplyAdd, double x, double y, double z); - FCDECL1_V(static int, IlogB, double x); + FCDECL1_V(static int, ILogB, double x); FCDECL1_V(static double, Log, double x); FCDECL1_V(static double, Log2, double x); FCDECL1_V(static double, Log10, double x); diff --git a/src/classlibnative/inc/floatsingle.h b/src/classlibnative/inc/floatsingle.h index f54a65028a..b23aea3ee7 100644 --- a/src/classlibnative/inc/floatsingle.h +++ b/src/classlibnative/inc/floatsingle.h @@ -26,7 +26,7 @@ public: FCDECL1_V(static float, Floor, float x); FCDECL2_VV(static float, FMod, float x, float y); FCDECL3_VVV(static float, FusedMultiplyAdd, float x, float y, float z); - FCDECL1_V(static int, IlogB, float x); + FCDECL1_V(static int, ILogB, float x); FCDECL1_V(static float, Log, float x); FCDECL1_V(static float, Log2, float x); FCDECL1_V(static float, Log10, float x); diff --git a/src/pal/src/config.h.in b/src/pal/src/config.h.in index 24ea14d39e..1ed071e33f 100644 --- a/src/pal/src/config.h.in +++ b/src/pal/src/config.h.in @@ -125,6 +125,8 @@ #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 diff --git a/src/pal/src/configure.cmake b/src/pal/src/configure.cmake index c8b4d44509..d105d851e3 100644 --- a/src/pal/src/configure.cmake +++ b/src/pal/src/configure.cmake @@ -833,6 +833,32 @@ check_cxx_source_runs(" #include <stdlib.h> 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 <math.h> +#include <stdlib.h> + +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 <math.h> +#include <stdlib.h> + +int main(void) { if (!isnan(log(-10000))) { exit(1); } diff --git a/src/pal/src/cruntime/math.cpp b/src/pal/src/cruntime/math.cpp index 126bbff551..9628cbd32d 100644 --- a/src/pal/src/cruntime/math.cpp +++ b/src/pal/src/cruntime/math.cpp @@ -340,7 +340,25 @@ PALIMPORT int __cdecl PAL_ilogb(double x) PERF_ENTRY(ilogb); ENTRY("ilogb (x=%f)\n", x); - ret = ilogb(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); @@ -855,7 +873,25 @@ PALIMPORT int __cdecl PAL_ilogbf(float x) PERF_ENTRY(ilogbf); ENTRY("ilogbf (x=%f)\n", x); - ret = ilogbf(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); diff --git a/src/pal/tests/palsuite/c_runtime/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/CMakeLists.txt index ba11c91096..3f3db60245 100644 --- a/src/pal/tests/palsuite/c_runtime/CMakeLists.txt +++ b/src/pal/tests/palsuite/c_runtime/CMakeLists.txt @@ -44,6 +44,8 @@ add_subdirectory(fflush) add_subdirectory(fgets) add_subdirectory(floor) add_subdirectory(floorf) +add_subdirectory(fma) +add_subdirectory(fmaf) add_subdirectory(fmod) add_subdirectory(fmodf) add_subdirectory(fopen) @@ -57,6 +59,8 @@ add_subdirectory(fwprintf) add_subdirectory(fwrite) add_subdirectory(getc) add_subdirectory(getenv) +add_subdirectory(ilogb) +add_subdirectory(ilogbf) add_subdirectory(isalnum) add_subdirectory(isalpha) add_subdirectory(isdigit) @@ -73,6 +77,8 @@ add_subdirectory(labs) add_subdirectory(llabs) add_subdirectory(localtime) add_subdirectory(log) +add_subdirectory(log2) +add_subdirectory(log2f) add_subdirectory(log10) add_subdirectory(log10f) add_subdirectory(logf) @@ -90,6 +96,8 @@ add_subdirectory(printf) add_subdirectory(qsort) add_subdirectory(rand_srand) add_subdirectory(realloc) +add_subdirectory(scalbn) +add_subdirectory(scalbnf) add_subdirectory(sin) add_subdirectory(sinf) add_subdirectory(sinh) diff --git a/src/pal/tests/palsuite/c_runtime/fma/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/fma/test1/test1.cpp index f6918d6ffd..b7d515dafc 100644 --- a/src/pal/tests/palsuite/c_runtime/fma/test1/test1.cpp +++ b/src/pal/tests/palsuite/c_runtime/fma/test1/test1.cpp @@ -93,8 +93,8 @@ int __cdecl main(int argc, char **argv) { /* x y z expected variance */ { PAL_NEGINF, PAL_NEGINF, PAL_NEGINF, PAL_NEGINF, 0 }, - { -1e308, 2, 1e300, -1e300, 0 }, - { 1e308, 2, -1e300, 1e300, 0 }, + { -1e308, 2, 1e308, -1e308, 0 }, + { 1e308, 2, -1e308, 1e308, 0 }, { PAL_POSINF, PAL_POSINF, PAL_POSINF, PAL_POSINF, 0 }, }; @@ -132,19 +132,14 @@ int __cdecl main(int argc, char **argv) // Returns NaN if (x * y) is infinite, and z is an infinite of the opposite sign validate_isnan(PAL_POSINF, PAL_POSINF, PAL_NEGINF); - validate_isnan(PAL_NEGINF, PAL_NEGINF, PAL_POSINF); + validate_isnan(PAL_NEGINF, PAL_NEGINF, PAL_NEGINF); validate_isnan(PAL_POSINF, PAL_NEGINF, PAL_POSINF); validate_isnan(PAL_NEGINF, PAL_POSINF, PAL_POSINF); validate_isnan(PAL_POSINF, 1, PAL_NEGINF); validate_isnan(PAL_NEGINF, 1, PAL_POSINF); - validate_isnan(PAL_POSINF, 1, PAL_POSINF); - validate_isnan(PAL_NEGINF, 1, PAL_POSINF); - validate_isnan(1, PAL_POSINF, PAL_NEGINF); validate_isnan(1, PAL_NEGINF, PAL_POSINF); - validate_isnan(1, PAL_NEGINF, PAL_POSINF); - validate_isnan(1, PAL_POSINF, PAL_POSINF); PAL_Terminate(); return PASS; diff --git a/src/pal/tests/palsuite/c_runtime/fmaf/test1/test1.c b/src/pal/tests/palsuite/c_runtime/fmaf/test1/test1.c index 7c3b5e391b..6c48d566e4 100644 --- a/src/pal/tests/palsuite/c_runtime/fmaf/test1/test1.c +++ b/src/pal/tests/palsuite/c_runtime/fmaf/test1/test1.c @@ -131,19 +131,14 @@ int __cdecl main(int argc, char **argv) // Returns NaN if (x * y) is infinite, and z is an infinite of the opposite sign validate_isnan(PAL_POSINF, PAL_POSINF, PAL_NEGINF); - validate_isnan(PAL_NEGINF, PAL_NEGINF, PAL_POSINF); + validate_isnan(PAL_NEGINF, PAL_NEGINF, PAL_NEGINF); validate_isnan(PAL_POSINF, PAL_NEGINF, PAL_POSINF); validate_isnan(PAL_NEGINF, PAL_POSINF, PAL_POSINF); validate_isnan(PAL_POSINF, 1, PAL_NEGINF); validate_isnan(PAL_NEGINF, 1, PAL_POSINF); - validate_isnan(PAL_POSINF, 1, PAL_POSINF); - validate_isnan(PAL_NEGINF, 1, PAL_POSINF); - validate_isnan(1, PAL_POSINF, PAL_NEGINF); validate_isnan(1, PAL_NEGINF, PAL_POSINF); - validate_isnan(1, PAL_NEGINF, PAL_POSINF); - validate_isnan(1, PAL_POSINF, PAL_POSINF); PAL_Terminate(); return PASS; diff --git a/src/pal/tests/palsuite/c_runtime/ilogb/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/ilogb/test1/test1.cpp index 5df6fcf355..0757e4e7ac 100644 --- a/src/pal/tests/palsuite/c_runtime/ilogb/test1/test1.cpp +++ b/src/pal/tests/palsuite/c_runtime/ilogb/test1/test1.cpp @@ -36,7 +36,7 @@ void __cdecl validate(double value, int expected) if (result != expected) { - Fail("ilogb(%g) returned %10.10g when it should have returned %10.10g", + Fail("ilogb(%g) returned %d when it should have returned %d", value, result, expected); } } @@ -51,23 +51,23 @@ int __cdecl main(int argc, char **argv) struct test tests[] = { /* value expected */ - { PAL_NEGINF, 0x80000000 }, - { 0, 0x80000000 }, - { PAL_POSINF, 0x80000000 }, - { 0.11331473229676087, -3 }, // expected: -(pi) - { 0.15195522325791297, -2 }, // expected: -(e) - { 0.20269956628651730, -2 }, // expected: -(ln(10)) - { 0.33662253682241906, -1 }, // expected: -(pi / 2) - { 0.36787944117144232, -1 }, // expected: -(log2(e)) - { 0.37521422724648177, -1 }, // expected: -(sqrt(2)) - { 0.45742934732229695, -1 }, // expected: -(2 / sqrt(pi)) + { 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, 0 }, // expected: -(pi / 4) - { 0.61254732653606592, 0 }, // expected: -(1 / sqrt(2)) - { 0.61850313780157598, 0 }, // expected: -(ln(2)) - { 0.64321824193300488, 0 }, // expected: -(2 / pi) - { 0.74005557395545179, 0 }, // expected: -(log10(e)) - { 0.80200887896145195, 0 }, // expected: -(1 / pi) + { 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) diff --git a/src/pal/tests/palsuite/c_runtime/ilogbf/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/ilogbf/test1/CMakeLists.txt index b478f698fc..0bebef8337 100644 --- a/src/pal/tests/palsuite/c_runtime/ilogbf/test1/CMakeLists.txt +++ b/src/pal/tests/palsuite/c_runtime/ilogbf/test1/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 2.8.12.2) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(SOURCES - test1.c + test1.cpp ) add_executable(paltest_ilogbf_test1 diff --git a/src/pal/tests/palsuite/c_runtime/ilogbf/test1/test1.c b/src/pal/tests/palsuite/c_runtime/ilogbf/test1/test1.cpp index 2b97e444f4..faa9f268cb 100644 --- a/src/pal/tests/palsuite/c_runtime/ilogbf/test1/test1.c +++ b/src/pal/tests/palsuite/c_runtime/ilogbf/test1/test1.cpp @@ -32,11 +32,11 @@ struct test */ void __cdecl validate(float value, int expected) { - float result = ilogbf(value); + int result = ilogbf(value); if (result != expected) { - Fail("ilogbf(%g) returned %10.10g when it should have returned %10.10g", + Fail("ilogbf(%g) returned %d when it should have returned %d", value, result, expected); } } @@ -51,23 +51,23 @@ int __cdecl main(int argc, char **argv) struct test tests[] = { /* value expected */ - { PAL_NEGINF, 0x80000000 }, - { 0, 0x80000000 }, - { PAL_POSINF, 0x80000000 }, - { 0.113314732f, -3 }, // expected: -(pi) - { 0.151955223f, -2 }, // expected: -(e) - { 0.202699566f, -2 }, // expected: -(ln(10)) - { 0.336622537f, -1 }, // expected: -(pi / 2) - { 0.367879441f, -1 }, // expected: -(log2(e)) - { 0.375214227f, -1 }, // expected: -(sqrt(2)) - { 0.457429347f, -1 }, // expected: -(2 / sqrt(pi)) + { 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, 0 }, // expected: -(pi / 4) - { 0.612547327f, 0 }, // expected: -(1 / sqrt(2)) - { 0.618503138f, 0 }, // expected: -(ln(2)) - { 0.643218242f, 0 }, // expected: -(2 / pi) - { 0.740055574f, 0 }, // expected: -(log10(e)) - { 0.802008879f, 0 }, // expected: -(1 / pi) + { 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) diff --git a/src/pal/tests/palsuite/c_runtime/log2/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/log2/test1/test1.cpp index c7900a0a93..0f73fa16a7 100644 --- a/src/pal/tests/palsuite/c_runtime/log2/test1/test1.cpp +++ b/src/pal/tests/palsuite/c_runtime/log2/test1/test1.cpp @@ -128,7 +128,7 @@ int __cdecl main(int argc, char **argv) for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) { - validate(tests[i].x, tests[i].y, tests[i].z, tests[i].expected, tests[i].variance); + validate(tests[i].value, tests[i].expected, tests[i].variance); } validate_isnan(PAL_NEGINF); diff --git a/src/pal/tests/palsuite/c_runtime/log2f/test1/test1.c b/src/pal/tests/palsuite/c_runtime/log2f/test1/test1.c index 5231aa5fcc..ed62e63204 100644 --- a/src/pal/tests/palsuite/c_runtime/log2f/test1/test1.c +++ b/src/pal/tests/palsuite/c_runtime/log2f/test1/test1.c @@ -127,7 +127,7 @@ int __cdecl main(int argc, char **argv) for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) { - validate(tests[i].x, tests[i].y, tests[i].z, tests[i].expected, tests[i].variance); + validate(tests[i].value, tests[i].expected, tests[i].variance); } validate_isnan(PAL_NEGINF); diff --git a/src/pal/tests/palsuite/paltestlist.txt b/src/pal/tests/palsuite/paltestlist.txt index 43998d0e83..861892a249 100644 --- a/src/pal/tests/palsuite/paltestlist.txt +++ b/src/pal/tests/palsuite/paltestlist.txt @@ -41,6 +41,8 @@ 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 @@ -93,6 +95,8 @@ c_runtime/getc/test1/paltest_getc_test1 c_runtime/getenv/test1/paltest_getenv_test1 c_runtime/getenv/test2/paltest_getenv_test2 c_runtime/getenv/test3/paltest_getenv_test3 +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 @@ -110,6 +114,8 @@ c_runtime/labs/test1/paltest_labs_test1 c_runtime/llabs/test1/paltest_llabs_test1 c_runtime/localtime/test1/paltest_localtime_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 @@ -147,6 +153,8 @@ 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/scalbn/test1/paltest_scalbn_test1 +c_runtime/scalbnf/test1/paltest_scalbnf_test1 c_runtime/sin/test1/paltest_sin_test1 c_runtime/sinf/test1/paltest_sinf_test1 c_runtime/sinh/test1/paltest_sinh_test1 diff --git a/src/pal/tests/palsuite/palverify.dat b/src/pal/tests/palsuite/palverify.dat index 697a080f5a..b39e7e7228 100644 --- a/src/pal/tests/palsuite/palverify.dat +++ b/src/pal/tests/palsuite/palverify.dat @@ -160,6 +160,8 @@ c_runtime/fgets/test2,1 c_runtime/fgets/test3,1 c_runtime/floor/test1,1 c_runtime/floorf/test1,1 +c_runtime/fma/test1,1 +c_runtime/fmaf/test1,1 c_runtime/fmod/test1,1 c_runtime/fmodf/test1,1 c_runtime/fopen/test1,1 @@ -220,6 +222,8 @@ c_runtime/getc/test1,1 c_runtime/getenv/test1,0 c_runtime/getenv/test2,1 c_runtime/getenv/test3,1 +c_runtime/ilogb/test1,1 +c_runtime/ilogbf/test1,1 c_runtime/isalnum/test1,1 c_runtime/isalpha/test1,1 c_runtime/isdigit/test1,1 @@ -238,6 +242,8 @@ c_runtime/labs/test1,1 c_runtime/llabs/test1,1 c_runtime/localtime/test1,1 c_runtime/log/test1,1 +c_runtime/log2/test1,1 +c_runtime/log2f/test1,1 c_runtime/log10/test1,1 c_runtime/log10f/test1,1 c_runtime/logf/test1,1 @@ -273,6 +279,8 @@ c_runtime/qsort/test1,1 c_runtime/qsort/test2,1 c_runtime/rand_srand/test1,1 c_runtime/realloc/test1,1 +c_runtime/scalbn/test1,1 +c_runtime/scalbnf/test1,1 c_runtime/sin/test1,1 c_runtime/sinf/test1,1 c_runtime/sinh/test1,1 diff --git a/src/vm/ecalllist.h b/src/vm/ecalllist.h index 31d3661d6f..6f812b3270 100644 --- a/src/vm/ecalllist.h +++ b/src/vm/ecalllist.h @@ -625,7 +625,7 @@ FCFuncStart(gMathFuncs) FCIntrinsic("Floor", COMDouble::Floor, CORINFO_INTRINSIC_Floor) FCFuncElement("FMod", COMDouble::FMod) FCFuncElement("FusedMultiplyAdd", COMDouble::FusedMultiplyAdd) - FCFuncElement("IlogB", COMDouble::IlogB) + FCFuncElement("ILogB", COMDouble::ILogB) FCFuncElement("Log", COMDouble::Log) FCFuncElement("Log2", COMDouble::Log2) FCIntrinsic("Log10", COMDouble::Log10, CORINFO_INTRINSIC_Log10) @@ -655,7 +655,7 @@ FCFuncStart(gMathFFuncs) FCIntrinsic("Floor", COMSingle::Floor, CORINFO_INTRINSIC_Floor) FCFuncElement("FMod", COMSingle::FMod) FCFuncElement("FusedMultiplyAdd", COMSingle::FusedMultiplyAdd) - FCFuncElement("IlogB", COMSingle::IlogB) + FCFuncElement("ILogB", COMSingle::ILogB) FCFuncElement("Log", COMSingle::Log) FCFuncElement("Log2", COMSingle::Log2) FCIntrinsic("Log10", COMSingle::Log10, CORINFO_INTRINSIC_Log10) diff --git a/tests/CoreFX/CoreFX.issues.json b/tests/CoreFX/CoreFX.issues.json index b784fbd635..45200012ad 100644 --- a/tests/CoreFX/CoreFX.issues.json +++ b/tests/CoreFX/CoreFX.issues.json @@ -525,6 +525,30 @@ "name": "System.Tests.ConvertToSingleTests.FromString", "reason": "https://github.com/dotnet/coreclr/pull/20707" }, + { + "name": "System.Tests.MathTests.Max_Double", + "reason": "https://github.com/dotnet/coreclr/pull/20912" + }, + { + "name": "System.Tests.MathTests.Max_Single", + "reason": "https://github.com/dotnet/coreclr/pull/20912" + }, + { + "name": "System.Tests.MathTests.Min_Double", + "reason": "https://github.com/dotnet/coreclr/pull/20912" + }, + { + "name": "System.Tests.MathTests.Min_Single", + "reason": "https://github.com/dotnet/coreclr/pull/20912" + }, + { + "name": "System.Tests.MathFTests.Max", + "reason": "https://github.com/dotnet/coreclr/pull/20912" + }, + { + "name": "System.Tests.MathFTests.Min", + "reason": "https://github.com/dotnet/coreclr/pull/20912" + }, ] } }, |