diff options
author | Tanner Gooding <tagoo@outlook.com> | 2017-09-23 14:23:23 -0700 |
---|---|---|
committer | Jan Kotas <jkotas@microsoft.com> | 2017-09-23 14:23:23 -0700 |
commit | bfaad966b593788a58cf213dbbea6645d6446920 (patch) | |
tree | 331e99b7f0bd594cb86487cda3bff7222323526f /src/classlibnative | |
parent | ededd38548f742a4ddb16e6af9fe4f4c82c64bef (diff) | |
download | coreclr-bfaad966b593788a58cf213dbbea6645d6446920.tar.gz coreclr-bfaad966b593788a58cf213dbbea6645d6446920.tar.bz2 coreclr-bfaad966b593788a58cf213dbbea6645d6446920.zip |
Moving parts of `System.Math` and `System.MathF` to be shared with CoreRT. (#14119)
* Moving parts of `System.MathF` to be shared with CoreRT.
* Moving parts of `System.Math` to be shared with CoreRT.
* Updating the new 'Round' named intrinsic to map to the legacy 'Round' intrinsic.
* Adding back the case statement for CORINFO_INTRINSIC_Round, since it is required for Desktop compat.
Diffstat (limited to 'src/classlibnative')
-rw-r--r-- | src/classlibnative/float/floatdouble.cpp | 37 | ||||
-rw-r--r-- | src/classlibnative/float/floatsingle.cpp | 37 | ||||
-rw-r--r-- | src/classlibnative/inc/floatdouble.h | 4 | ||||
-rw-r--r-- | src/classlibnative/inc/floatsingle.h | 4 |
4 files changed, 26 insertions, 56 deletions
diff --git a/src/classlibnative/float/floatdouble.cpp b/src/classlibnative/float/floatdouble.cpp index ba90a57f88..419a889871 100644 --- a/src/classlibnative/float/floatdouble.cpp +++ b/src/classlibnative/float/floatdouble.cpp @@ -132,6 +132,15 @@ FCIMPL1_V(double, COMDouble::Floor, double x) return (double)floor(x); FCIMPLEND +/*=====================================FMod===================================== +** +==============================================================================*/ +FCIMPL2_VV(double, COMDouble::FMod, double x, double y) + FCALL_CONTRACT; + + return (double)fmod(x, y); +FCIMPLEND + /*=====================================Log====================================== ** ==============================================================================*/ @@ -153,10 +162,10 @@ FCIMPLEND /*=====================================ModF===================================== ** ==============================================================================*/ -FCIMPL1(double, COMDouble::ModF, double* iptr) +FCIMPL2_VV(double, COMDouble::ModF, double x, double* intptr) FCALL_CONTRACT; - return (double)modf(*iptr, iptr); + return (double)modf(x, intptr); FCIMPLEND /*=====================================Pow====================================== @@ -168,30 +177,6 @@ FCIMPL2_VV(double, COMDouble::Pow, double x, double y) return (double)pow(x, y); FCIMPLEND -/*====================================Round===================================== -** -==============================================================================*/ -FCIMPL1_V(double, COMDouble::Round, double x) - FCALL_CONTRACT; - - // If the number has no fractional part do nothing - // This shortcut is necessary to workaround precision loss in borderline cases on some platforms - if (x == (double)((INT64)x)) { - return x; - } - - // We had a number that was equally close to 2 integers. - // We need to return the even one. - - double flrTempVal = floor(x + 0.5); - - if ((x == (floor(x) + 0.5)) && (fmod(flrTempVal, 2.0) != 0)) { - flrTempVal -= 1.0; - } - - return _copysign(flrTempVal, x); -FCIMPLEND - /*=====================================Sin====================================== ** ==============================================================================*/ diff --git a/src/classlibnative/float/floatsingle.cpp b/src/classlibnative/float/floatsingle.cpp index ba48aea709..6e5021aedc 100644 --- a/src/classlibnative/float/floatsingle.cpp +++ b/src/classlibnative/float/floatsingle.cpp @@ -130,6 +130,15 @@ FCIMPL1_V(float, COMSingle::Floor, float x) return (float)floorf(x); FCIMPLEND +/*=====================================FMod===================================== +** +==============================================================================*/ +FCIMPL2_VV(float, COMSingle::FMod, float x, float y) + FCALL_CONTRACT; + + return (float)fmodf(x, y); +FCIMPLEND + /*=====================================Log====================================== ** ==============================================================================*/ @@ -151,10 +160,10 @@ FCIMPLEND /*=====================================ModF===================================== ** ==============================================================================*/ -FCIMPL1(float, COMSingle::ModF, float* iptr) +FCIMPL2_VV(float, COMSingle::ModF, float x, float* intptr) FCALL_CONTRACT; - return (float)modff(*iptr, iptr); + return (float)modff(x, intptr); FCIMPLEND /*=====================================Pow====================================== @@ -166,30 +175,6 @@ FCIMPL2_VV(float, COMSingle::Pow, float x, float y) return (float)powf(x, y); FCIMPLEND -/*====================================Round===================================== -** -==============================================================================*/ -FCIMPL1_V(float, COMSingle::Round, float x) - FCALL_CONTRACT; - - // If the number has no fractional part do nothing - // This shortcut is necessary to workaround precision loss in borderline cases on some platforms - if (x == (float)((INT32)x)) { - return x; - } - - // We had a number that was equally close to 2 integers. - // We need to return the even one. - - float flrTempVal = floorf(x + 0.5f); - - if ((x == (floorf(x) + 0.5f)) && (fmod(flrTempVal, 2.0f) != 0)) { - flrTempVal -= 1.0f; - } - - return _copysignf(flrTempVal, x); -FCIMPLEND - /*=====================================Sin====================================== ** ==============================================================================*/ diff --git a/src/classlibnative/inc/floatdouble.h b/src/classlibnative/inc/floatdouble.h index 16403c1f36..0d195e1ace 100644 --- a/src/classlibnative/inc/floatdouble.h +++ b/src/classlibnative/inc/floatdouble.h @@ -20,11 +20,11 @@ public: FCDECL1_V(static double, Cosh, double x); FCDECL1_V(static double, Exp, double x); FCDECL1_V(static double, Floor, double x); + FCDECL2_VV(static double, FMod, double x, double y); FCDECL1_V(static double, Log, double x); FCDECL1_V(static double, Log10, double x); - FCDECL1(static double, ModF, double* iptr); + FCDECL2_VV(static double, ModF, double x, double* intptr); FCDECL2_VV(static double, Pow, double x, double y); - FCDECL1_V(static double, Round, double x); FCDECL1_V(static double, Sin, double x); FCDECL1_V(static double, Sinh, double x); FCDECL1_V(static double, Sqrt, double x); diff --git a/src/classlibnative/inc/floatsingle.h b/src/classlibnative/inc/floatsingle.h index 8296e2d37a..912278c913 100644 --- a/src/classlibnative/inc/floatsingle.h +++ b/src/classlibnative/inc/floatsingle.h @@ -20,11 +20,11 @@ public: FCDECL1_V(static float, Cosh, float x); FCDECL1_V(static float, Exp, float x); FCDECL1_V(static float, Floor, float x); + FCDECL2_VV(static float, FMod, float x, float y); FCDECL1_V(static float, Log, float x); FCDECL1_V(static float, Log10, float x); - FCDECL1(static float, ModF, float* iptr); + FCDECL2_VV(static float, ModF, float x, float* intptr); FCDECL2_VV(static float, Pow, float x, float y); - FCDECL1_V(static float, Round, float x); FCDECL1_V(static float, Sin, float x); FCDECL1_V(static float, Sinh, float x); FCDECL1_V(static float, Sqrt, float x); |