Skip to content

Commit

Permalink
add RiscV64 support, fixes #2644
Browse files Browse the repository at this point in the history
  • Loading branch information
adamsitnik committed Sep 25, 2024
1 parent 52485ec commit e088392
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/BenchmarkDotNet/Environments/Platform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,10 @@ public enum Platform
/// A PowerPC 64-bit (little-endian) processor architecture.
/// </summary>
Ppc64le,

/// <summary>
/// A RiscV 64-bit processor architecture.
/// </summary>
RiscV64,
}
}
5 changes: 4 additions & 1 deletion src/BenchmarkDotNet/Portability/RuntimeInformation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,13 @@ internal static Runtime GetCurrentRuntime()
public static Platform GetCurrentPlatform()
{
// these are not part of .NET Standard 2.0, so we use hardcoded values taken from
// https://github.com/dotnet/runtime/blob/1a37caf773a3b857ccff49a31be3333d4fdc491f/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Architecture.cs#L9
// https://github.com/dotnet/runtime/blob/080fcae7eaa8367abf7900e08ff2e52e3efea5bf/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Architecture.cs#L9
const Architecture Wasm = (Architecture)4;
const Architecture S390x = (Architecture)5;
const Architecture LoongArch64 = (Architecture)6;
const Architecture Armv6 = (Architecture)7;
const Architecture Ppc64le = (Architecture)8;
const Architecture RiscV64 = (Architecture)9;

switch (ProcessArchitecture)
{
Expand All @@ -234,6 +235,8 @@ public static Platform GetCurrentPlatform()
return Platform.Armv6;
case Ppc64le:
return Platform.Ppc64le;
case RiscV64:
return Platform.RiscV64;
default:
throw new ArgumentOutOfRangeException();
}
Expand Down

0 comments on commit e088392

Please sign in to comment.