Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert Math{F}.CoreCLR methods from FCall to QCall #39474

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions eng/DefaultGenApiDocIds.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ T:System.Runtime.InteropServices.ComVisibleAttribute
T:System.Runtime.InteropServices.GuidAttribute
T:System.Runtime.InteropServices.LCIDConversionAttribute
T:System.Runtime.InteropServices.StructLayoutAttribute
T:System.Runtime.InteropServices.SuppressGCTransitionAttribute
T:System.Security.Permissions.EnvironmentPermissionAttribute
T:System.Security.Permissions.FileIOPermissionAttribute
T:System.Security.Permissions.HostProtectionAttribute
Expand Down
95 changes: 65 additions & 30 deletions src/coreclr/src/System.Private.CoreLib/src/System/Math.CoreCLR.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,119 +11,154 @@
===========================================================*/

using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

namespace System
{
public static partial class Math
{
#pragma warning disable CA1401 // P/Invokes should not be visible

[Intrinsic]
am11 marked this conversation as resolved.
Show resolved Hide resolved
[MethodImpl(MethodImplOptions.InternalCall)]
[SuppressGCTransition]
[DllImport(RuntimeHelpers.QCall, CallingConvention = CallingConvention.Cdecl)]
public static extern double Abs(double value);

[SuppressGCTransition]
[DllImport(RuntimeHelpers.QCall, CallingConvention = CallingConvention.Cdecl)]
private static extern float AbsF(float value);
jkotas marked this conversation as resolved.
Show resolved Hide resolved
[Intrinsic]
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern float Abs(float value);
public static float Abs(float value) => AbsF(value);

[Intrinsic]
[MethodImpl(MethodImplOptions.InternalCall)]
[SuppressGCTransition]
[DllImport(RuntimeHelpers.QCall, CallingConvention = CallingConvention.Cdecl)]
public static extern double Acos(double d);

[Intrinsic]
[MethodImpl(MethodImplOptions.InternalCall)]
[SuppressGCTransition]
[DllImport(RuntimeHelpers.QCall, CallingConvention = CallingConvention.Cdecl)]
public static extern double Acosh(double d);

[Intrinsic]
[MethodImpl(MethodImplOptions.InternalCall)]
[SuppressGCTransition]
[DllImport(RuntimeHelpers.QCall, CallingConvention = CallingConvention.Cdecl)]
public static extern double Asin(double d);

[Intrinsic]
[MethodImpl(MethodImplOptions.InternalCall)]
[SuppressGCTransition]
[DllImport(RuntimeHelpers.QCall, CallingConvention = CallingConvention.Cdecl)]
public static extern double Asinh(double d);

[Intrinsic]
[MethodImpl(MethodImplOptions.InternalCall)]
[SuppressGCTransition]
[DllImport(RuntimeHelpers.QCall, CallingConvention = CallingConvention.Cdecl)]
public static extern double Atan(double d);

[Intrinsic]
[MethodImpl(MethodImplOptions.InternalCall)]
[SuppressGCTransition]
[DllImport(RuntimeHelpers.QCall, CallingConvention = CallingConvention.Cdecl)]
public static extern double Atan2(double y, double x);

[Intrinsic]
[MethodImpl(MethodImplOptions.InternalCall)]
[SuppressGCTransition]
[DllImport(RuntimeHelpers.QCall, CallingConvention = CallingConvention.Cdecl)]
public static extern double Atanh(double d);

[Intrinsic]
[MethodImpl(MethodImplOptions.InternalCall)]
[SuppressGCTransition]
[DllImport(RuntimeHelpers.QCall, CallingConvention = CallingConvention.Cdecl)]
public static extern double Cbrt(double d);

[Intrinsic]
[MethodImpl(MethodImplOptions.InternalCall)]
[SuppressGCTransition]
[DllImport(RuntimeHelpers.QCall, CallingConvention = CallingConvention.Cdecl)]
public static extern double Ceiling(double a);

[Intrinsic]
[MethodImpl(MethodImplOptions.InternalCall)]
[SuppressGCTransition]
[DllImport(RuntimeHelpers.QCall, CallingConvention = CallingConvention.Cdecl)]
public static extern double Cos(double d);

[Intrinsic]
[MethodImpl(MethodImplOptions.InternalCall)]
[SuppressGCTransition]
[DllImport(RuntimeHelpers.QCall, CallingConvention = CallingConvention.Cdecl)]
public static extern double Cosh(double value);

[Intrinsic]
[MethodImpl(MethodImplOptions.InternalCall)]
[SuppressGCTransition]
[DllImport(RuntimeHelpers.QCall, CallingConvention = CallingConvention.Cdecl)]
public static extern double Exp(double d);

[Intrinsic]
[MethodImpl(MethodImplOptions.InternalCall)]
[SuppressGCTransition]
[DllImport(RuntimeHelpers.QCall, CallingConvention = CallingConvention.Cdecl)]
public static extern double Floor(double d);

[Intrinsic]
[MethodImpl(MethodImplOptions.InternalCall)]
[SuppressGCTransition]
[DllImport(RuntimeHelpers.QCall, CallingConvention = CallingConvention.Cdecl)]
public static extern double FusedMultiplyAdd(double x, double y, double z);

[MethodImpl(MethodImplOptions.InternalCall)]
[SuppressGCTransition]
[DllImport(RuntimeHelpers.QCall, CallingConvention = CallingConvention.Cdecl)]
public static extern int ILogB(double x);

[MethodImpl(MethodImplOptions.InternalCall)]
[SuppressGCTransition]
[DllImport(RuntimeHelpers.QCall, CallingConvention = CallingConvention.Cdecl)]
public static extern double Log(double d);

[MethodImpl(MethodImplOptions.InternalCall)]
[SuppressGCTransition]
[DllImport(RuntimeHelpers.QCall, CallingConvention = CallingConvention.Cdecl)]
public static extern double Log2(double x);

[Intrinsic]
[MethodImpl(MethodImplOptions.InternalCall)]
[SuppressGCTransition]
[DllImport(RuntimeHelpers.QCall, CallingConvention = CallingConvention.Cdecl)]
public static extern double Log10(double d);

[Intrinsic]
[MethodImpl(MethodImplOptions.InternalCall)]
[SuppressGCTransition]
[DllImport(RuntimeHelpers.QCall, CallingConvention = CallingConvention.Cdecl)]
public static extern double Pow(double x, double y);

[MethodImpl(MethodImplOptions.InternalCall)]
[SuppressGCTransition]
[DllImport(RuntimeHelpers.QCall, CallingConvention = CallingConvention.Cdecl)]
public static extern double ScaleB(double x, int n);

[Intrinsic]
[MethodImpl(MethodImplOptions.InternalCall)]
[SuppressGCTransition]
[DllImport(RuntimeHelpers.QCall, CallingConvention = CallingConvention.Cdecl)]
public static extern double Sin(double a);

[Intrinsic]
[MethodImpl(MethodImplOptions.InternalCall)]
[SuppressGCTransition]
[DllImport(RuntimeHelpers.QCall, CallingConvention = CallingConvention.Cdecl)]
public static extern double Sinh(double value);

[Intrinsic]
[MethodImpl(MethodImplOptions.InternalCall)]
[SuppressGCTransition]
[DllImport(RuntimeHelpers.QCall, CallingConvention = CallingConvention.Cdecl)]
public static extern double Sqrt(double d);

[Intrinsic]
[MethodImpl(MethodImplOptions.InternalCall)]
[SuppressGCTransition]
[DllImport(RuntimeHelpers.QCall, CallingConvention = CallingConvention.Cdecl)]
public static extern double Tan(double a);

[Intrinsic]
[MethodImpl(MethodImplOptions.InternalCall)]
[SuppressGCTransition]
[DllImport(RuntimeHelpers.QCall, CallingConvention = CallingConvention.Cdecl)]
public static extern double Tanh(double value);

[MethodImpl(MethodImplOptions.InternalCall)]
#pragma warning restore CA1401 // P/Invokes should not be visible

[SuppressGCTransition]
[DllImport(RuntimeHelpers.QCall, CallingConvention = CallingConvention.Cdecl)]
private static extern double FMod(double x, double y);

[MethodImpl(MethodImplOptions.InternalCall)]
[SuppressGCTransition]
[DllImport(RuntimeHelpers.QCall, CallingConvention = CallingConvention.Cdecl)]
private static extern unsafe double ModF(double x, double* intptr);
}
}
86 changes: 59 additions & 27 deletions src/coreclr/src/System.Private.CoreLib/src/System/MathF.CoreCLR.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,111 +8,143 @@
===========================================================*/

using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

namespace System
{
public static partial class MathF
{
#pragma warning disable CA1401 // P/Invokes should not be visible

[Intrinsic]
[MethodImpl(MethodImplOptions.InternalCall)]
[SuppressGCTransition]
[DllImport(RuntimeHelpers.QCall, CallingConvention = CallingConvention.Cdecl)]
public static extern float Acos(float x);

[Intrinsic]
[MethodImpl(MethodImplOptions.InternalCall)]
[SuppressGCTransition]
[DllImport(RuntimeHelpers.QCall, CallingConvention = CallingConvention.Cdecl)]
public static extern float Acosh(float x);

[Intrinsic]
[MethodImpl(MethodImplOptions.InternalCall)]
[SuppressGCTransition]
[DllImport(RuntimeHelpers.QCall, CallingConvention = CallingConvention.Cdecl)]
public static extern float Asin(float x);

[Intrinsic]
[MethodImpl(MethodImplOptions.InternalCall)]
[SuppressGCTransition]
[DllImport(RuntimeHelpers.QCall, CallingConvention = CallingConvention.Cdecl)]
public static extern float Asinh(float x);

[Intrinsic]
[MethodImpl(MethodImplOptions.InternalCall)]
[SuppressGCTransition]
[DllImport(RuntimeHelpers.QCall, CallingConvention = CallingConvention.Cdecl)]
public static extern float Atan(float x);

[Intrinsic]
[MethodImpl(MethodImplOptions.InternalCall)]
[SuppressGCTransition]
[DllImport(RuntimeHelpers.QCall, CallingConvention = CallingConvention.Cdecl)]
public static extern float Atan2(float y, float x);

[Intrinsic]
[MethodImpl(MethodImplOptions.InternalCall)]
[SuppressGCTransition]
[DllImport(RuntimeHelpers.QCall, CallingConvention = CallingConvention.Cdecl)]
public static extern float Atanh(float x);

[Intrinsic]
[MethodImpl(MethodImplOptions.InternalCall)]
[SuppressGCTransition]
[DllImport(RuntimeHelpers.QCall, CallingConvention = CallingConvention.Cdecl)]
public static extern float Cbrt(float x);

[Intrinsic]
[MethodImpl(MethodImplOptions.InternalCall)]
[SuppressGCTransition]
[DllImport(RuntimeHelpers.QCall, CallingConvention = CallingConvention.Cdecl)]
public static extern float Ceiling(float x);

[Intrinsic]
[MethodImpl(MethodImplOptions.InternalCall)]
[SuppressGCTransition]
[DllImport(RuntimeHelpers.QCall, CallingConvention = CallingConvention.Cdecl)]
public static extern float Cos(float x);

[Intrinsic]
[MethodImpl(MethodImplOptions.InternalCall)]
[SuppressGCTransition]
[DllImport(RuntimeHelpers.QCall, CallingConvention = CallingConvention.Cdecl)]
public static extern float Cosh(float x);

[Intrinsic]
[MethodImpl(MethodImplOptions.InternalCall)]
[SuppressGCTransition]
[DllImport(RuntimeHelpers.QCall, CallingConvention = CallingConvention.Cdecl)]
public static extern float Exp(float x);

[Intrinsic]
[MethodImpl(MethodImplOptions.InternalCall)]
[SuppressGCTransition]
[DllImport(RuntimeHelpers.QCall, CallingConvention = CallingConvention.Cdecl)]
public static extern float Floor(float x);

[Intrinsic]
[MethodImpl(MethodImplOptions.InternalCall)]
[SuppressGCTransition]
[DllImport(RuntimeHelpers.QCall, CallingConvention = CallingConvention.Cdecl)]
public static extern float FusedMultiplyAdd(float x, float y, float z);

[MethodImpl(MethodImplOptions.InternalCall)]
[SuppressGCTransition]
[DllImport(RuntimeHelpers.QCall, CallingConvention = CallingConvention.Cdecl)]
public static extern int ILogB(float x);

[MethodImpl(MethodImplOptions.InternalCall)]
[SuppressGCTransition]
[DllImport(RuntimeHelpers.QCall, CallingConvention = CallingConvention.Cdecl)]
public static extern float Log(float x);

[MethodImpl(MethodImplOptions.InternalCall)]
[SuppressGCTransition]
[DllImport(RuntimeHelpers.QCall, CallingConvention = CallingConvention.Cdecl)]
public static extern float Log2(float x);

[Intrinsic]
[MethodImpl(MethodImplOptions.InternalCall)]
[SuppressGCTransition]
[DllImport(RuntimeHelpers.QCall, CallingConvention = CallingConvention.Cdecl)]
public static extern float Log10(float x);

[Intrinsic]
[MethodImpl(MethodImplOptions.InternalCall)]
[SuppressGCTransition]
[DllImport(RuntimeHelpers.QCall, CallingConvention = CallingConvention.Cdecl)]
public static extern float Pow(float x, float y);

[MethodImpl(MethodImplOptions.InternalCall)]
[SuppressGCTransition]
[DllImport(RuntimeHelpers.QCall, CallingConvention = CallingConvention.Cdecl)]
public static extern float ScaleB(float x, int n);

[Intrinsic]
[MethodImpl(MethodImplOptions.InternalCall)]
[SuppressGCTransition]
[DllImport(RuntimeHelpers.QCall, CallingConvention = CallingConvention.Cdecl)]
public static extern float Sin(float x);

[Intrinsic]
[MethodImpl(MethodImplOptions.InternalCall)]
[SuppressGCTransition]
[DllImport(RuntimeHelpers.QCall, CallingConvention = CallingConvention.Cdecl)]
public static extern float Sinh(float x);

[Intrinsic]
[MethodImpl(MethodImplOptions.InternalCall)]
[SuppressGCTransition]
[DllImport(RuntimeHelpers.QCall, CallingConvention = CallingConvention.Cdecl)]
public static extern float Sqrt(float x);

[Intrinsic]
[MethodImpl(MethodImplOptions.InternalCall)]
[SuppressGCTransition]
[DllImport(RuntimeHelpers.QCall, CallingConvention = CallingConvention.Cdecl)]
public static extern float Tan(float x);

[Intrinsic]
[MethodImpl(MethodImplOptions.InternalCall)]
[SuppressGCTransition]
[DllImport(RuntimeHelpers.QCall, CallingConvention = CallingConvention.Cdecl)]
public static extern float Tanh(float x);

[MethodImpl(MethodImplOptions.InternalCall)]
#pragma warning restore CA1401 // P/Invokes should not be visible

[SuppressGCTransition]
[DllImport(RuntimeHelpers.QCall, CallingConvention = CallingConvention.Cdecl)]
private static extern float FMod(float x, float y);

[MethodImpl(MethodImplOptions.InternalCall)]
[SuppressGCTransition]
[DllImport(RuntimeHelpers.QCall, CallingConvention = CallingConvention.Cdecl)]
private static extern unsafe float ModF(float x, float* intptr);
}
}
1 change: 0 additions & 1 deletion src/coreclr/src/classlibnative/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ include_directories("../debug/inc")
include_directories("../debug/inc/dump")

add_subdirectory(bcltype)
add_subdirectory(float)
18 changes: 0 additions & 18 deletions src/coreclr/src/classlibnative/float/CMakeLists.txt

This file was deleted.

Loading