Skip to content

Commit

Permalink
Use _SC_NPROCESSORS_CONF instead of _SC_NPROCESSORS_ONLN in Unix_Proc…
Browse files Browse the repository at this point in the history
…essorCountTest on ARM/ARM64 (dotnet/corefx#30128)

* See dotnet/coreclr#18289

Commit migrated from dotnet/corefx@ab52915
  • Loading branch information
echesakov authored and stephentoub committed Jun 5, 2018
1 parent c13a375 commit caca77a
Showing 1 changed file with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,25 @@ public void Windows_ProcessorCountTest()
public void Unix_ProcessorCountTest()
{
//arrange
int _SC_NPROCESSORS_ONLN =
RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? 84 :
RuntimeInformation.IsOSPlatform(OSPlatform.Create("NETBSD")) ? 1002 :
58;
int expected = (int)sysconf(_SC_NPROCESSORS_ONLN);
int SYSCONF_GET_NUMPROCS;

if (RuntimeInformation.ProcessArchitecture == Architecture.Arm ||
RuntimeInformation.ProcessArchitecture == Architecture.Arm64)
{
SYSCONF_GET_NUMPROCS = /* _SC_NPROCESSORS_CONF */
RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? 83 :
RuntimeInformation.IsOSPlatform(OSPlatform.Create("NETBSD")) ? 1001 :
57;
}
else
{
SYSCONF_GET_NUMPROCS = /* _SC_NPROCESSORS_ONLN */
RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? 84 :
RuntimeInformation.IsOSPlatform(OSPlatform.Create("NETBSD")) ? 1002 :
58;
}

int expected = (int)sysconf(SYSCONF_GET_NUMPROCS);

//act
int actual = Environment.ProcessorCount;
Expand Down

0 comments on commit caca77a

Please sign in to comment.