Browse Source

Using zero bytes as the error code for cache lines.

David Piuva 10 months ago
parent
commit
52947684a0
1 changed files with 3 additions and 3 deletions
  1. 3 3
      Source/DFPSR/base/heap.cpp

+ 3 - 3
Source/DFPSR/base/heap.cpp

@@ -64,11 +64,11 @@ namespace dsr {
 			snprintf(path, sizeof(path), "/sys/devices/system/cpu/cpu%i/cache/index%i/coherency_line_size", (int)cpuIndex, (int)cacheLevel);
 			snprintf(path, sizeof(path), "/sys/devices/system/cpu/cpu%i/cache/index%i/coherency_line_size", (int)cpuIndex, (int)cacheLevel);
 			FILE *file = fopen(path, "r");
 			FILE *file = fopen(path, "r");
 			if (file == nullptr) {
 			if (file == nullptr) {
-				return -1;
+				return 0;
 			}
 			}
 			int cacheLineSize;
 			int cacheLineSize;
 			if (fscanf(file, "%i", &cacheLineSize) != 1) {
 			if (fscanf(file, "%i", &cacheLineSize) != 1) {
-				cacheLineSize = -1;
+				cacheLineSize = 0;
 			}
 			}
 			fclose(file);
 			fclose(file);
 			return uintptr_t(cacheLineSize);
 			return uintptr_t(cacheLineSize);
@@ -79,7 +79,7 @@ namespace dsr {
 			uintptr_t cacheLevel = 0;
 			uintptr_t cacheLevel = 0;
 			while (true) {
 			while (true) {
 				uintptr_t newSize = getCacheLineSizeFromIndices(cpuIndex, cacheLevel);
 				uintptr_t newSize = getCacheLineSizeFromIndices(cpuIndex, cacheLevel);
-				if (newSize == -1) {
+				if (newSize == 0) {
 					if (cacheLevel == 0) {
 					if (cacheLevel == 0) {
 						// CPU does not exist, so we are done.
 						// CPU does not exist, so we are done.
 						break;
 						break;