Skip to content

Commit dabec4f

Browse files
committed
get SYS_gettid value specific to given architecture (and hopefully fix the build for arm64)
1 parent 0de6947 commit dabec4f

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/libraries/System.Diagnostics.Process/tests/ProcessThreadTests.Unix.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,23 @@ public void TestPriorityLevelProperty_Unix()
3232
Assert.Throws<PlatformNotSupportedException>(() => thread.PriorityLevel = level);
3333
}
3434

35-
private static int GetCurrentThreadId() => syscall(186); // SYS_gettid
35+
private static int GetCurrentThreadId()
36+
{
37+
// The magic values come from https://github.com/torvalds/linux.
38+
int SYS_gettid = RuntimeInformation.ProcessArchitecture switch
39+
{
40+
Architecture.Arm => 224,
41+
Architecture.Arm64 => 178,
42+
Architecture.X86 => 224,
43+
Architecture.X64 => 186,
44+
Architecture.S390x => 236,
45+
Architecture.Ppc64le => 207,
46+
Architecture.RiscV64 => 178,
47+
_ => 178,
48+
};
49+
50+
return syscall(SYS_gettid);
51+
}
3652

3753
[DllImport("libc")]
3854
private static extern int syscall(int nr);

0 commit comments

Comments
 (0)