From: Ayabusa Date: Thu, 4 Jun 2026 18:44:40 +0000 (+0200) Subject: Started implementing the CPU specs detection X-Git-Url: https://git.ayabusa.dev/?a=commitdiff_plain;h=1dbed4b3a6ead310acf74fd30a4de51716ec418e;p=thoryum.git Started implementing the CPU specs detection --- diff --git a/src/cpu.c b/src/cpu.c new file mode 100644 index 0000000..33cfdeb --- /dev/null +++ b/src/cpu.c @@ -0,0 +1,20 @@ +#include +#include "cpu.h" + +// Great article https://wiki.osdev.org/CPUID +// GCC ref in gcc/config/i386/cpuid.h +enum CPU_opti CPU_fetch_opti() { + unsigned int eax, ebx, ecx, edx; + __get_cpuid(1, &eax, &ebx, &ecx, &edx); // We gather the CPU specs + + if (ebx & bit_AVX2) // gold tier + return AVX2; + else if (ecx & bit_AVX) + return AVX; + else if ((ecx & bit_SSE4_1) || (ecx & bit_SSE4_2)) // No idea why there are two lol + return SSE4; + else if (ecx & bit_SSE3) // Not a complete piece of trash + return SSE3; + else + return POTATO; // Bruh... You in the 50s or wat ? +} diff --git a/src/cpu.h b/src/cpu.h new file mode 100644 index 0000000..b6ee415 --- /dev/null +++ b/src/cpu.h @@ -0,0 +1,14 @@ +#ifndef CPU_H +#define CPU_H + +enum CPU_opti { + POTATO, + SSE3, + SSE4, + AVX, + AVX2, +}; + +enum CPU_opti CPU_fetch_opti(); + +#endif