Skip to content
Prev Previous commit
Next Next commit
Change from std:string to char[]
  • Loading branch information
kunalspathak committed Jun 21, 2022
commit c7c905a5facfd07788c64bc6d838eb9c1e46da10
10 changes: 7 additions & 3 deletions src/coreclr/gc/unix/gcenv.unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -910,12 +910,16 @@ static size_t GetLogicalProcessorCacheSizeFromOS()
// this method to determine cache size.
//
size_t level;
char path_to_size_file[] = "/sys/devices/system/cpu/cpu0/cache/index-/size";
char path_to_level_file[] = "/sys/devices/system/cpu/cpu0/cache/index-/level";
int index = 40;
for (int i = 0; i < 5; i++)
{
string path_to_index = "/sys/devices/system/cpu/cpu0/cache/index" + to_string(i);
if (ReadMemoryValueFromFile((path_to_index + "/size").c_str(), &size))
path_to_size_file[index] = (char)(48 + i);
if (ReadMemoryValueFromFile(path_to_size_file, &size))
{
if (ReadMemoryValueFromFile((path_to_index + "/level").c_str(), &level))
path_to_level_file[index] = (char)(48 + i);
if (ReadMemoryValueFromFile(path_to_level_file, &level))
{
CHECK_CACHE_SIZE(level)
}
Expand Down
10 changes: 7 additions & 3 deletions src/coreclr/pal/src/misc/sysinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -575,12 +575,16 @@ PAL_GetLogicalProcessorCacheSizeFromOS()
// this method to determine cache size.
//
size_t level;
char path_to_size_file[] = "/sys/devices/system/cpu/cpu0/cache/index-/size";
char path_to_level_file[] = "/sys/devices/system/cpu/cpu0/cache/index-/level";
int index = 40;
for (int i = 0; i < 5; i++)
{
string path_to_index = "/sys/devices/system/cpu/cpu0/cache/index" + to_string(i);
if (ReadMemoryValueFromFile((path_to_index + "/size").c_str(), &size))
path_to_size_file[index] = (char)(48 + i);
if (ReadMemoryValueFromFile(path_to_size_file, &size))
{
if (ReadMemoryValueFromFile((path_to_index + "/level").c_str(), &level))
path_to_level_file[index] = (char)(48 + i);
if (ReadMemoryValueFromFile(path_to_level_file, &level))
{
CHECK_CACHE_SIZE(level)
}
Expand Down