Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsergey ignatov <sergign60@mail.ru>2017-02-27 19:51:01 +0300
committerJan Kotas <jkotas@microsoft.com>2017-02-27 19:51:01 +0300
commit3e057ae6e249c8289a5e6221e046e7cea364a3c0 (patch)
tree9b3944f3ca8aace8de911a7344e48b6aa187050c /src/Native/Runtime/unix
parent2774952ffe03b950bed3adab63204ca0ca822b83 (diff)
[arm32 unix building] Passing target platform and os to IlcCompiler for cross compiling (#2793)
* Passing target platform&os to IlcCompiler * Deleted /sys/devices/system/cpu/cache parsing * Added empty version of InteropThunksHelpers for arm
Diffstat (limited to 'src/Native/Runtime/unix')
-rw-r--r--src/Native/Runtime/unix/PalRedhawkUnix.cpp90
1 files changed, 29 insertions, 61 deletions
diff --git a/src/Native/Runtime/unix/PalRedhawkUnix.cpp b/src/Native/Runtime/unix/PalRedhawkUnix.cpp
index 1c2fa1d2b..22d59579f 100644
--- a/src/Native/Runtime/unix/PalRedhawkUnix.cpp
+++ b/src/Native/Runtime/unix/PalRedhawkUnix.cpp
@@ -704,73 +704,41 @@ REDHAWK_PALEXPORT void PalPrintFatalError(const char* message)
write(STDERR_FILENO, message, sizeof(message));
}
+#ifdef __linux__
+size_t
+GetLogicalProcessorCacheSizeFromOS()
+{
+ size_t cacheSize = 0;
+
+#ifdef _SC_LEVEL1_DCACHE_SIZE
+ cacheSize = max(cacheSize, sysconf(_SC_LEVEL1_DCACHE_SIZE));
+#endif
+#ifdef _SC_LEVEL2_CACHE_SIZE
+ cacheSize = max(cacheSize, sysconf(_SC_LEVEL2_CACHE_SIZE));
+#endif
+#ifdef _SC_LEVEL3_CACHE_SIZE
+ cacheSize = max(cacheSize, sysconf(_SC_LEVEL3_CACHE_SIZE));
+#endif
+#ifdef _SC_LEVEL4_CACHE_SIZE
+ cacheSize = max(cacheSize, sysconf(_SC_LEVEL4_CACHE_SIZE));
+#endif
+ return cacheSize;
+}
+#endif
+
bool QueryCacheSize()
{
bool success = true;
g_cbLargestOnDieCache = 0;
#ifdef __linux__
- DIR* cpuDir = opendir("/sys/devices/system/cpu");
- if (cpuDir == nullptr)
- {
- ASSERT_UNCONDITIONALLY("opendir on /sys/devices/system/cpu failed\n");
- return false;
- }
-
- dirent* cpuEntry;
- // Process entries starting with "cpu" (cpu0, cpu1, ...) in the directory
- while (success && (cpuEntry = readdir(cpuDir)) != nullptr)
- {
- if ((strncmp(cpuEntry->d_name, "cpu", 3) == 0) && isdigit(cpuEntry->d_name[3]))
- {
- char cpuCachePath[64] = "/sys/devices/system/cpu/";
- strcat(cpuCachePath, cpuEntry->d_name);
- strcat(cpuCachePath, "/cache");
- DIR* cacheDir = opendir(cpuCachePath);
- if (cacheDir == nullptr)
- {
- success = false;
- break;
- }
-
- strcat(cpuCachePath, "/");
- int cpuCacheBasePathLength = strlen(cpuCachePath);
-
- dirent* cacheEntry;
- // For all entries in the directory
- while ((cacheEntry = readdir(cacheDir)) != nullptr)
- {
- if (strncmp(cacheEntry->d_name, "index", 5) == 0)
- {
- cpuCachePath[cpuCacheBasePathLength] = '\0';
- strcat(cpuCachePath, cacheEntry->d_name);
- strcat(cpuCachePath, "/size");
-
- int fd = open(cpuCachePath, O_RDONLY);
- if (fd < 0)
- {
- success = false;
- break;
- }
- char cacheSizeStr[16];
- int bytesRead = read(fd, cacheSizeStr, sizeof(cacheSizeStr) - 1);
- cacheSizeStr[bytesRead] = '\0';
-
- // Parse the cache size that is formatted as a number followed by the K letter
- char* lastChar;
- int cacheSize = strtol(cacheSizeStr, &lastChar, 10) * 1024;
- ASSERT(*lastChar == 'K');
- g_cbLargestOnDieCache = max(g_cbLargestOnDieCache, cacheSize);
-
- close(fd);
- }
- }
-
- closedir(cacheDir);
- }
- }
- closedir(cpuDir);
+ g_cbLargestOnDieCache = GetLogicalProcessorCacheSizeFromOS();
+#ifndef _ARM_
+ // TODO Some systems on arm does not give the info about cache sizes by this method so we need to find another way
+ if (g_cbLargestOnDieCache == 0)
+ success = false;
+#endif
#elif HAVE_SYSCTL
@@ -791,7 +759,7 @@ bool QueryCacheSize()
}
}
#else
-#error Don't know how to get cache size on this platform
+#error Do not know how to get cache size on this platform
#endif // __linux__
// TODO: implement adjusted cache size