Skip to content

Commit

Permalink
Merge pull request #2108 from CosmosOS/fix/intrinsics
Browse files Browse the repository at this point in the history
Add plugs to disable intrinsics
  • Loading branch information
MishaTy committed Feb 10, 2022
2 parents d1ac2c2 + fae927d commit 6b08c75
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ public static void Execute()
result = value.ToString();
expectedResult = "255";

Assert.IsTrue((result == expectedResult), "Byte.ToString doesn't work");
Assert.AreEqual(result, expectedResult, "Byte.ToString doesn't work");
Assert.AreEqual("ff", value.ToString("x"), "Byte.ToString('x') doesn't work");
Assert.AreEqual("FF", value.ToString("X"), "Byte.ToString('X') doesn't work");

// Now let's try to concat to a String using '+' operator
result = "The Maximum value of a Byte is " + value;
Expand All @@ -36,14 +38,6 @@ public static void Execute()
// actually the Hash Code of a Byte is the same value expressed as int
Assert.IsTrue((resultAsInt == value), "Byte.GetHashCode() doesn't work");

#if false
// Now let's try ToString() again but printed in hex (this test fails for now!)
result = value.ToString("X2");
expectedResult = "FF";

Assert.IsTrue((result == expectedResult), "Byte.ToString(X2) doesn't work");
#endif

// basic bit operations

int val2;
Expand Down
27 changes: 27 additions & 0 deletions source/Cosmos.Core_Plugs/Runtime/Intrinsics/X86/LzcntImpl.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using IL2CPU.API.Attribs;

namespace Cosmos.Core_Plugs.Runtime.Intrinsics.X86
{
[Plug("System.Runtime.Intrinsics.X86.Lzcnt, System.Private.CoreLib")]
class LzcntImpl
{
public static bool get_IsSupported()
{
return false;
}
}

[Plug("System.Runtime.Intrinsics.X86.Lzcnt+X64, System.Private.CoreLib")]
class X64LzcntImpl
{
public static bool get_IsSupported()
{
return false;
}
}
}
9 changes: 9 additions & 0 deletions source/Cosmos.Core_Plugs/Runtime/Intrinsics/X86/X86Base.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,13 @@ public static bool get_IsSupported()
return false;
}
}

[Plug("System.Runtime.Intrinsics.X86.X86Base+X64, System.Private.CoreLib")]
class X64X86BaseImpl
{
public static bool get_IsSupported()
{
return false;
}
}
}

0 comments on commit 6b08c75

Please sign in to comment.