summaryrefslogtreecommitdiff
path: root/src/pal/src
diff options
context:
space:
mode:
authorTanner Gooding <tagoo@outlook.com>2018-11-05 15:37:36 -0800
committerGitHub <noreply@github.com>2018-11-05 15:37:36 -0800
commit28417584d8e98ae7eac22e92b952778f8ea94047 (patch)
treea6010a24228ca769fc7a6381cbd04b3a762e9219 /src/pal/src
parentd3a7c973723bf2610c7dcdcd00318c06a72a36f8 (diff)
downloadcoreclr-28417584d8e98ae7eac22e92b952778f8ea94047.tar.gz
coreclr-28417584d8e98ae7eac22e92b952778f8ea94047.tar.bz2
coreclr-28417584d8e98ae7eac22e92b952778f8ea94047.zip
Adding some new functions to System.Math and System.MathF (#20788)
* Adding BitIncrement, BitDecrement, CopySign, MaxMagnitude, and MinMagnitude to Math and MathF * Adding FusedMultiplyAdd, IlogB, Log2, and ScaleB to Math and MathF * Adding some basic PAL tests for fma, ilogb, log2, and scalbn * Fixing a couple typos and adding clarifying comments * Fixing the MSVC _VVV FCALL declarations
Diffstat (limited to 'src/pal/src')
-rw-r--r--src/pal/src/cruntime/math.cpp152
-rw-r--r--src/pal/src/include/pal/palinternal.h8
2 files changed, 160 insertions, 0 deletions
diff --git a/src/pal/src/cruntime/math.cpp b/src/pal/src/cruntime/math.cpp
index af2f99416e..126bbff551 100644
--- a/src/pal/src/cruntime/math.cpp
+++ b/src/pal/src/cruntime/math.cpp
@@ -311,6 +311,44 @@ PALIMPORT double __cdecl PAL_exp(double x)
/*++
Function:
+ fma
+
+See MSDN.
+--*/
+PALIMPORT double __cdecl PAL_fma(double x, double y, double z)
+{
+ double ret;
+ PERF_ENTRY(fma);
+ ENTRY("fma (x=%f, y=%f, z=%f)\n", x, y, z);
+
+ ret = fma(x, y, z);
+
+ LOGEXIT("fma returns double %f\n", ret);
+ PERF_EXIT(fma);
+ return ret;
+}
+
+/*++
+Function:
+ ilogb
+
+See MSDN.
+--*/
+PALIMPORT int __cdecl PAL_ilogb(double x)
+{
+ int ret;
+ PERF_ENTRY(ilogb);
+ ENTRY("ilogb (x=%f)\n", x);
+
+ ret = ilogb(x);
+
+ LOGEXIT("ilogb returns int %d\n", ret);
+ PERF_EXIT(ilogb);
+ return ret;
+}
+
+/*++
+Function:
labs
See MSDN.
@@ -360,6 +398,25 @@ PALIMPORT double __cdecl PAL_log(double x)
/*++
Function:
+ log2
+
+See MSDN.
+--*/
+PALIMPORT double __cdecl PAL_log2(double x)
+{
+ double ret;
+ PERF_ENTRY(log2);
+ ENTRY("log2 (x=%f)\n", x);
+
+ ret = log2(x);
+
+ LOGEXIT("log2 returns double %f\n", ret);
+ PERF_EXIT(log2);
+ return ret;
+}
+
+/*++
+Function:
log10
See MSDN.
@@ -483,6 +540,25 @@ 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:
_signbitf
Determines whether given single-precision floating point value has a negative sign.
@@ -750,6 +826,44 @@ PALIMPORT float __cdecl PAL_expf(float x)
/*++
Function:
+ fmaf
+
+See MSDN.
+--*/
+PALIMPORT float __cdecl PAL_fmaf(float x, float y, float z)
+{
+ float ret;
+ PERF_ENTRY(fmaf);
+ ENTRY("fmaf (x=%f, y=%f, z=%f)\n", x, y, z);
+
+ ret = fmaf(x, y, z);
+
+ LOGEXIT("fma returns float %f\n", ret);
+ PERF_EXIT(fmaf);
+ return ret;
+}
+
+/*++
+Function:
+ ilogbf
+
+See MSDN.
+--*/
+PALIMPORT int __cdecl PAL_ilogbf(float x)
+{
+ int ret;
+ PERF_ENTRY(ilogbf);
+ ENTRY("ilogbf (x=%f)\n", x);
+
+ ret = ilogbf(x);
+
+ LOGEXIT("ilogbf returns int %d\n", ret);
+ PERF_EXIT(ilogbf);
+ return ret;
+}
+
+/*++
+Function:
logf
See MSDN.
@@ -780,6 +894,25 @@ PALIMPORT float __cdecl PAL_logf(float x)
/*++
Function:
+ log2f
+
+See MSDN.
+--*/
+PALIMPORT float __cdecl PAL_log2f(float x)
+{
+ float ret;
+ PERF_ENTRY(log2f);
+ ENTRY("log2f (x=%f)\n", x);
+
+ ret = log2f(x);
+
+ LOGEXIT("log2f returns float %f\n", ret);
+ PERF_EXIT(log2f);
+ return ret;
+}
+
+/*++
+Function:
log10f
See MSDN.
@@ -894,3 +1027,22 @@ PALIMPORT float __cdecl PAL_powf(float x, float y)
PERF_EXIT(powf);
return ret;
}
+
+/*++
+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 double %f\n", ret);
+ PERF_EXIT(scalbnf);
+ return ret;
+}
diff --git a/src/pal/src/include/pal/palinternal.h b/src/pal/src/include/pal/palinternal.h
index 69e4f5fdb9..0e37ba84c0 100644
--- a/src/pal/src/include/pal/palinternal.h
+++ b/src/pal/src/include/pal/palinternal.h
@@ -461,10 +461,14 @@ function_name() to call the system's implementation
#undef fabs
#undef floor
#undef fmod
+#undef fma
+#undef ilogb
#undef log
+#undef log2
#undef log10
#undef modf
#undef pow
+#undef scalbn
#undef sin
#undef sinh
#undef sqrt
@@ -485,10 +489,14 @@ function_name() to call the system's implementation
#undef fabsf
#undef floorf
#undef fmodf
+#undef fmaf
+#undef ilogbf
#undef logf
+#undef log2f
#undef log10f
#undef modff
#undef powf
+#undef scalbnf
#undef sinf
#undef sinhf
#undef sqrtf