Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/dotnet/runtime.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Covington <68252706+alexcovington@users.noreply.github.com>2021-01-26 01:11:45 +0300
committerGitHub <noreply@github.com>2021-01-26 01:11:45 +0300
commit220bf9714248cca8ef18cb4175ae83b1cf210a70 (patch)
tree0d131d191c69b9260931f2f80f88aff544b27591 /src/coreclr/pal
parent9f8aab73d93156933ae65a476204bf62c02f6537 (diff)
Added C# implementation of System.Math.ScaleB and System.MathF.ScaleB… (#42476)
* Added C# implementation of System.Math.ScaleB and System.MathF.ScaleB, removed old bindings, added test cases. * Moved tests into System.Runtime.Extensions tests. * Removed unmanaged scalbn and scalbnf from pal and mono * Update src/libraries/System.Private.CoreLib/src/System/Math.cs Co-authored-by: Adeel Mujahid <adeelbm@outlook.com> * Styling changes. * Conditionally include ScaleB for Mono. * Update src/mono/mono/metadata/sysmath.c Tabs, not spaces. Co-authored-by: Adeel Mujahid <adeelbm@outlook.com> * Removing more scalb from PAL * Completely removed ScaleB from Mono * Cleaning up more scalbn * Added comments for ScaleB, updated licenses for musl and Sun * Fixed whitespace. * Removing old references, fixing double ScaleB definition that merge didn't resolve Co-authored-by: Adeel Mujahid <adeelbm@outlook.com>
Diffstat (limited to 'src/coreclr/pal')
-rw-r--r--src/coreclr/pal/inc/pal.h4
-rw-r--r--src/coreclr/pal/src/cruntime/math.cpp38
-rw-r--r--src/coreclr/pal/src/include/pal/palinternal.h2
-rw-r--r--src/coreclr/pal/tests/palsuite/CMakeLists.txt2
-rw-r--r--src/coreclr/pal/tests/palsuite/c_runtime/scalbn/test1/test1.cpp139
-rw-r--r--src/coreclr/pal/tests/palsuite/c_runtime/scalbnf/test1/test1.cpp138
-rw-r--r--src/coreclr/pal/tests/palsuite/compilableTests.txt2
-rw-r--r--src/coreclr/pal/tests/palsuite/paltestlist.txt2
8 files changed, 0 insertions, 327 deletions
diff --git a/src/coreclr/pal/inc/pal.h b/src/coreclr/pal/inc/pal.h
index 5eb1544b72e..95eeee758f8 100644
--- a/src/coreclr/pal/inc/pal.h
+++ b/src/coreclr/pal/inc/pal.h
@@ -3807,7 +3807,6 @@ PAL_GetCurrentThreadAffinitySet(SIZE_T size, UINT_PTR* data);
#define log2 PAL_log2
#define log10 PAL_log10
#define pow PAL_pow
-#define scalbn PAL_scalbn
#define sincos PAL_sincos
#define acosf PAL_acosf
#define acoshf PAL_acoshf
@@ -3821,7 +3820,6 @@ PAL_GetCurrentThreadAffinitySet(SIZE_T size, UINT_PTR* data);
#define log2f PAL_log2f
#define log10f PAL_log10f
#define powf PAL_powf
-#define scalbnf PAL_scalbnf
#define sincosf PAL_sincosf
#define malloc PAL_malloc
#define free PAL_free
@@ -4091,7 +4089,6 @@ PALIMPORT double __cdecl log2(double);
PALIMPORT double __cdecl log10(double);
PALIMPORT double __cdecl modf(double, double*);
PALIMPORT double __cdecl pow(double, double);
-PALIMPORT double __cdecl scalbn(double, int);
PALIMPORT double __cdecl sin(double);
PALIMPORT void __cdecl sincos(double, double*, double*);
PALIMPORT double __cdecl sinh(double);
@@ -4136,7 +4133,6 @@ PALIMPORT float __cdecl log2f(float);
PALIMPORT float __cdecl log10f(float);
PALIMPORT float __cdecl modff(float, float*);
PALIMPORT float __cdecl powf(float, float);
-PALIMPORT float __cdecl scalbnf(float, int);
PALIMPORT float __cdecl sinf(float);
PALIMPORT void __cdecl sincosf(float, float*, float*);
PALIMPORT float __cdecl sinhf(float);
diff --git a/src/coreclr/pal/src/cruntime/math.cpp b/src/coreclr/pal/src/cruntime/math.cpp
index 940f08a8408..33898bdbbfa 100644
--- a/src/coreclr/pal/src/cruntime/math.cpp
+++ b/src/coreclr/pal/src/cruntime/math.cpp
@@ -510,25 +510,6 @@ PALIMPORT double __cdecl PAL_pow(double x, double y)
/*++
Function:
- scalbn
-
-See MSDN.
---*/
-PALIMPORT double __cdecl PAL_scalbn(double x, int n)
-{
- double ret;
- PERF_ENTRY(scalbn);
- ENTRY("scalbn (x=%f, n=%d)\n", x, n);
-
- ret = scalbn(x, n);
-
- LOGEXIT("scalbn returns double %f\n", ret);
- PERF_EXIT(scalbn);
- return ret;
-}
-
-/*++
-Function:
sincos
See MSDN.
@@ -1011,25 +992,6 @@ PALIMPORT float __cdecl PAL_powf(float x, float y)
/*++
Function:
- scalbnf
-
-See MSDN.
---*/
-PALIMPORT float __cdecl PAL_scalbnf(float x, int n)
-{
- float ret;
- PERF_ENTRY(scalbnf);
- ENTRY("scalbnf (x=%f, n=%d)\n", x, n);
-
- ret = scalbnf(x, n);
-
- LOGEXIT("scalbnf returns float %f\n", ret);
- PERF_EXIT(scalbnf);
- return ret;
-}
-
-/*++
-Function:
sincosf
See MSDN.
diff --git a/src/coreclr/pal/src/include/pal/palinternal.h b/src/coreclr/pal/src/include/pal/palinternal.h
index bd35139779b..b0abe2aa9be 100644
--- a/src/coreclr/pal/src/include/pal/palinternal.h
+++ b/src/coreclr/pal/src/include/pal/palinternal.h
@@ -458,7 +458,6 @@ function_name() to call the system's implementation
#undef log10
#undef modf
#undef pow
-#undef scalbn
#undef sin
#undef sincos
#undef sinh
@@ -487,7 +486,6 @@ function_name() to call the system's implementation
#undef log10f
#undef modff
#undef powf
-#undef scalbnf
#undef sinf
#undef sincosf
#undef sinhf
diff --git a/src/coreclr/pal/tests/palsuite/CMakeLists.txt b/src/coreclr/pal/tests/palsuite/CMakeLists.txt
index a62cd38b9c1..f59e6f43f96 100644
--- a/src/coreclr/pal/tests/palsuite/CMakeLists.txt
+++ b/src/coreclr/pal/tests/palsuite/CMakeLists.txt
@@ -224,8 +224,6 @@ _add_executable(paltests
c_runtime/qsort/test2/test2.cpp
c_runtime/rand_srand/test1/test1.cpp
c_runtime/realloc/test1/test1.cpp
- c_runtime/scalbn/test1/test1.cpp
- c_runtime/scalbnf/test1/test1.cpp
c_runtime/sin/test1/test1.cpp
c_runtime/sincos/test1/test1.cpp
c_runtime/sincosf/test1/test1.cpp
diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/scalbn/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/scalbn/test1/test1.cpp
deleted file mode 100644
index a36f2de02ed..00000000000
--- a/src/coreclr/pal/tests/palsuite/c_runtime/scalbn/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 that scalbn returns correct values.
-**
-**===================================================================*/
-
-#include <palsuite.h>
-
-// 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 */
- int exponent; /* exponent to test the function with */
- double expected; /* expected result */
- double variance; /* maximum delta between the expected and actual result */
-};
-
-/**
- * scalbn_test1_validate
- *
- * test validation function
- */
-void __cdecl scalbn_test1_validate(double value, int exponent, double expected, double variance)
-{
- double result = scalbn(value, exponent);
-
- /*
- * 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("scalbn(%g, %d) returned %20.17g when it should have returned %20.17g\n",
- value, exponent, result, expected);
- }
-}
-
-/**
- * scalbn_test1_validate
- *
- * test validation function for values returning NaN
- */
-void __cdecl scalbn_test1_validate_isnan(double value, int exponent)
-{
- double result = scalbn(value, exponent);
-
- if (!_isnan(result))
- {
- Fail("scalbn(%g, %d) returned %20.17g when it should have returned %20.17g\n",
- value, exponent, result, PAL_NAN);
- }
-}
-
-/**
- * main
- *
- * executable entry point
- */
-PALTEST(c_runtime_scalbn_test1_paltest_scalbn_test1, "c_runtime/scalbn/test1/paltest_scalbn_test1")
-{
- struct test tests[] =
- {
- /* value exponent expected variance */
- { PAL_NEGINF, 0x80000000, PAL_NEGINF, 0 },
- { 0, 0x80000000, 0, 0 },
- { 0.11331473229676087, -3, 0.014164341537095108, PAL_EPSILON / 10 },
- { 0.15195522325791297, -2, 0.037988805814478242, PAL_EPSILON / 10 },
- { 0.20269956628651730, -2, 0.050674891571629327, PAL_EPSILON / 10 },
- { 0.33662253682241906, -1, 0.16831126841120952, PAL_EPSILON },
- { 0.36787944117144232, -1, 0.18393972058572117, PAL_EPSILON },
- { 0.37521422724648177, -1, 0.1876071136232409, PAL_EPSILON },
- { 0.45742934732229695, -1, 0.22871467366114848, PAL_EPSILON },
- { 0.5, -1, 0.25, PAL_EPSILON },
- { 0.58019181037172444, 0, 0.5801918103717244, PAL_EPSILON },
- { 0.61254732653606592, 0, 0.61254732653606592, PAL_EPSILON },
- { 0.61850313780157598, 0, 0.61850313780157595, PAL_EPSILON },
- { 0.64321824193300488, 0, 0.64321824193300492, PAL_EPSILON },
- { 0.74005557395545179, 0, 0.74005557395545174, PAL_EPSILON },
- { 0.80200887896145195, 0, 0.8020088789614519, PAL_EPSILON },
- { 1, 0, 1, PAL_EPSILON * 10 },
- { 1.2468689889006383, 0, 1.2468689889006384, PAL_EPSILON * 10 },
- { 1.3512498725672678, 0, 1.3512498725672677, PAL_EPSILON * 10 },
- { 1.5546822754821001, 0, 1.5546822754821001, PAL_EPSILON * 10 },
- { 1.6168066722416747, 0, 1.6168066722416747, PAL_EPSILON * 10 },
- { 1.6325269194381528, 0, 1.6325269194381529, PAL_EPSILON * 10 },
- { 1.7235679341273495, 0, 1.7235679341273495, PAL_EPSILON * 10 },
- { 2, 1, 4, PAL_EPSILON * 10 },
- { 2.1861299583286618, 1, 4.3722599166573239, PAL_EPSILON * 10 },
- { 2.6651441426902252, 1, 5.3302882853804503, PAL_EPSILON * 10 },
- { 2.7182818284590452, 1, 5.4365636569180902, PAL_EPSILON * 10 },
- { 2.9706864235520193, 1, 5.9413728471040388, PAL_EPSILON * 10 },
- { 4.9334096679145963, 2, 19.733638671658387, PAL_EPSILON * 100 },
- { 6.5808859910179210, 2, 26.323543964071686, PAL_EPSILON * 100 },
- { 8.8249778270762876, 3, 70.599822616610297, PAL_EPSILON * 100 },
- { PAL_POSINF, 0x80000000, PAL_POSINF, 0 },
- };
-
- if (PAL_Initialize(argc, argv) != 0)
- {
- return FAIL;
- }
-
- for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++)
- {
- scalbn_test1_validate(tests[i].value, tests[i].exponent, tests[i].expected, tests[i].variance);
- }
-
- scalbn_test1_validate_isnan(PAL_NAN, 2147483647);
-
- PAL_Terminate();
- return PASS;
-}
diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/scalbnf/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/scalbnf/test1/test1.cpp
deleted file mode 100644
index 28ac6405bfe..00000000000
--- a/src/coreclr/pal/tests/palsuite/c_runtime/scalbnf/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 scalbnf returns correct values.
-**
-**===================================================================*/
-
-#include <palsuite.h>
-
-// 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 */
- int exponent; /* exponent to test the function with */
- float expected; /* expected result */
- float variance; /* maximum delta between the expected and actual result */
-};
-
-/**
- * scalbnf_test1_validate
- *
- * test validation function
- */
-void __cdecl scalbnf_test1_validate(float value, int exponent, float expected, float variance)
-{
- float result = scalbnf(value, exponent);
-
- /*
- * 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("scalbnf(%g, %g) returned %10.9g when it should have returned %10.9g",
- value, exponent, result, expected);
- }
-}
-
-/**
- * scalbnf_test1_validate
- *
- * test validation function for values returning NaN
- */
-void __cdecl scalbnf_test1_validate_isnan(float value, int exponent)
-{
- float result = scalbnf(value, exponent);
-
- if (!_isnanf(result))
- {
- Fail("scalbnf(%g, %g) returned %10.9g when it should have returned %10.9g",
- value, exponent, result, PAL_NAN);
- }
-}
-
-/**
- * main
- *
- * executable entry point
- */
-PALTEST(c_runtime_scalbnf_test1_paltest_scalbnf_test1, "c_runtime/scalbnf/test1/paltest_scalbnf_test1")
-{
- struct test tests[] =
- {
- /* value exponent expected variance */
- { PAL_NEGINF, 0x80000000, PAL_NEGINF, 0 },
- { 0, 0x80000000, 0, 0 },
- { 0.113314732f, -3, 0.0141643415f, PAL_EPSILON / 10 },
- { 0.151955223f, -2, 0.0379888058f, PAL_EPSILON / 10 },
- { 0.202699566f, -2, 0.0506748916f, PAL_EPSILON / 10 },
- { 0.336622537f, -1, 0.168311268f, PAL_EPSILON },
- { 0.367879441f, -1, 0.183939721f, PAL_EPSILON },
- { 0.375214227f, -1, 0.187607114f, PAL_EPSILON },
- { 0.457429347f, -1, 0.228714674f, PAL_EPSILON },
- { 0.5f, -1, 0.25f, PAL_EPSILON },
- { 0.580191810f, 0, 0.580191810f, PAL_EPSILON },
- { 0.612547327f, 0, 0.612547327f, PAL_EPSILON },
- { 0.618503138f, 0, 0.618503138f, PAL_EPSILON },
- { 0.643218242f, 0, 0.643218242f, PAL_EPSILON },
- { 0.740055574f, 0, 0.740055574f, PAL_EPSILON },
- { 0.802008879f, 0, 0.802008879f, PAL_EPSILON },
- { 1, 0, 1, PAL_EPSILON * 10 },
- { 1.24686899f, 0, 1.24686899f, PAL_EPSILON * 10 },
- { 1.35124987f, 0, 1.35124987f, PAL_EPSILON * 10 },
- { 1.55468228f, 0, 1.55468228f, PAL_EPSILON * 10 },
- { 1.61680667f, 0, 1.61680667f, PAL_EPSILON * 10 },
- { 1.63252692f, 0, 1.63252692f, PAL_EPSILON * 10 },
- { 1.72356793f, 0, 1.72356793f, PAL_EPSILON * 10 },
- { 2, 1, 4, PAL_EPSILON * 10 },
- { 2.18612996f, 1, 4.37225992f, PAL_EPSILON * 10 },
- { 2.66514414f, 1, 5.33028829f, PAL_EPSILON * 10 },
- { 2.71828183f, 1, 5.43656366f, PAL_EPSILON * 10 },
- { 2.97068642f, 1, 5.94137285f, PAL_EPSILON * 10 },
- { 4.93340967f, 2, 19.7336387f, PAL_EPSILON * 100 },
- { 6.58088599f, 2, 26.3235440f, PAL_EPSILON * 100 },
- { 8.82497783f, 3, 70.5998226f, PAL_EPSILON * 100 },
- { PAL_POSINF, 0x80000000, PAL_POSINF, 0 },
- };
-
- if (PAL_Initialize(argc, argv) != 0)
- {
- return FAIL;
- }
-
- for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++)
- {
- scalbnf_test1_validate(tests[i].value, tests[i].exponent, tests[i].expected, tests[i].variance);
- }
-
- scalbnf_test1_validate_isnan(PAL_NAN, 2147483647);
-
- PAL_Terminate();
- return PASS;
-}
diff --git a/src/coreclr/pal/tests/palsuite/compilableTests.txt b/src/coreclr/pal/tests/palsuite/compilableTests.txt
index 8df635989bf..c674de294db 100644
--- a/src/coreclr/pal/tests/palsuite/compilableTests.txt
+++ b/src/coreclr/pal/tests/palsuite/compilableTests.txt
@@ -159,8 +159,6 @@ 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/sincos/test1/paltest_sincos_test1
c_runtime/sincosf/test1/paltest_sincosf_test1
diff --git a/src/coreclr/pal/tests/palsuite/paltestlist.txt b/src/coreclr/pal/tests/palsuite/paltestlist.txt
index 70f4b599c71..2b9ac7ccd4e 100644
--- a/src/coreclr/pal/tests/palsuite/paltestlist.txt
+++ b/src/coreclr/pal/tests/palsuite/paltestlist.txt
@@ -148,8 +148,6 @@ 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/sincos/test1/paltest_sincos_test1
c_runtime/sincosf/test1/paltest_sincosf_test1