Skip to content

Commit

Permalink
[RISC-V] Initial commit for libraries directory
Browse files Browse the repository at this point in the history
  • Loading branch information
t-mustafin committed Sep 12, 2023
1 parent 8622e98 commit 78b9df5
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public static partial class PlatformDetection
public static bool IsS390xProcess => (int)RuntimeInformation.ProcessArchitecture == 5; // Architecture.S390x
public static bool IsArmv6Process => (int)RuntimeInformation.ProcessArchitecture == 7; // Architecture.Armv6
public static bool IsPpc64leProcess => (int)RuntimeInformation.ProcessArchitecture == 8; // Architecture.Ppc64le
public static bool IsRiscV64Process => (int)RuntimeInformation.ProcessArchitecture == 9; // Architecture.RiscV64;
public static bool IsX64Process => RuntimeInformation.ProcessArchitecture == Architecture.X64;
public static bool IsX86Process => RuntimeInformation.ProcessArchitecture == Architecture.X86;
public static bool IsNotX86Process => !IsX86Process;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,12 @@ public enum Architecture
/// A PowerPC 64-bit (little-endian) processor architecture.
/// </summary>
Ppc64le,
/// <summary>
/// A RiscV 64-bit processor architecture.
/// </summary>
/// <remarks>
/// This value indicates RV64GC set of extensions.
/// </remarks>
RiscV64,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public static Architecture ProcessArchitecture
#elif TARGET_POWERPC64
=> Architecture.Ppc64le
#elif TARGET_RISCV64
=> (Architecture)9 // TODO-RISCV64: go though API review for RiscV64
=> Architecture.RiscV64
#else
#error Unknown Architecture
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3293,6 +3293,9 @@ public enum Machine : ushort
Arm64 = (ushort)43620,
LoongArch32 = (ushort)25138,
LoongArch64 = (ushort)25188,
RiscV32 = (ushort)20530,
RiscV64 = (ushort)20580,
RiscV128 = (ushort)20776,
}
public partial class ManagedPEBuilder : System.Reflection.PortableExecutable.PEBuilder
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,5 +139,20 @@ public enum Machine : ushort
/// LOONGARCH64
/// </summary>
LoongArch64 = 0x6264,

/// <summary>
/// RISCV32
/// </summary>
RiscV32 = 0x5032,

/// <summary>
/// RISCV64
/// </summary>
RiscV64 = 0x5064,

/// <summary>
/// RISCV128
/// </summary>
RiscV128 = 0x5128,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ public void Sizes()
Assert.Equal(128 + 4 + 20 + 224 + 16, new PEHeaderBuilder(Machine.Arm64).ComputeSizeOfPEHeaders(0));
Assert.Equal(128 + 4 + 20 + 224 + 16 + 40 * 1, new PEHeaderBuilder(Machine.Arm64).ComputeSizeOfPEHeaders(1));
Assert.Equal(128 + 4 + 20 + 224 + 16 + 40 * 2, new PEHeaderBuilder(Machine.Arm64).ComputeSizeOfPEHeaders(2));
Assert.Equal(128 + 4 + 20 + 224 + 16, new PEHeaderBuilder(Machine.RiscV64).ComputeSizeOfPEHeaders(0));
Assert.Equal(128 + 4 + 20 + 224 + 16 + 40 * 1, new PEHeaderBuilder(Machine.RiscV64).ComputeSizeOfPEHeaders(1));
Assert.Equal(128 + 4 + 20 + 224 + 16 + 40 * 2, new PEHeaderBuilder(Machine.RiscV64).ComputeSizeOfPEHeaders(2));
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ public void VerifyArchitecture()
Assert.Equal(Architecture.Ppc64le, processArch);
break;

case Architecture.RiscV64:
Assert.Equal(Architecture.RiscV64, processArch);
break;

default:
Assert.False(true, "Unexpected Architecture.");
break;
Expand Down
1 change: 1 addition & 0 deletions src/libraries/System.Runtime/ref/System.Runtime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13395,6 +13395,7 @@ public enum Architecture
LoongArch64 = 6,
Armv6 = 7,
Ppc64le = 8,
RiscV64 = 9,
}
public enum CharSet
{
Expand Down

0 comments on commit 78b9df5

Please sign in to comment.