From b5e2da2d14e850e9d1b29c7797b1f4b09b4f7873 Mon Sep 17 00:00:00 2001 From: ColumbusTech Date: Thu, 22 Nov 2018 13:57:19 +0300 Subject: [PATCH] Comments --- corinfo.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/corinfo.h b/corinfo.h index eb5428c..41155f1 100644 --- a/corinfo.h +++ b/corinfo.h @@ -102,6 +102,7 @@ static void __extensions(int cpu[4], struct corinfo* info); if (sysinfo(&sys) == -1) return -1; int cpu[4]; + // CPUID 0x00 code returns in EAX maximum CPUID code and vendor string in EBX, EDX, ECX. __cpuid(cpu, 0x00000000); __vendor_string(cpu, info->VendorString); __brand_string(cpu, info->BrandString); @@ -109,12 +110,13 @@ static void __extensions(int cpu[4], struct corinfo* info); info->CpuCount = sysconf(_SC_NPROCESSORS_ONLN); + // /proc/cpuinfo reading is necessary for CPUs not implementing CPUID 0x16 code. FILE* f = fopen("/proc/cpuinfo", "rb"); if (f == NULL) return -1; - char* line = NULL; - size_t line_length = 0; - size_t line_read = 0; + char* line = NULL; + size_t line_length = 0; + ssize_t line_read = 0; while ((line_read = getline(&line, &line_length, f)) != -1) {