+static const char *cpuids[] = {
+ "Nooooooooone",
+ "AMDisbetter!",
+ "AuthenticAMD",
+ "CentaurHauls",
+ "CyrixInstead",
+ "GenuineIntel",
+ "TransmetaCPU",
+ "GeniuneTMx86",
+ "Geode by NSC",
+ "NexGenDriven",
+ "RiseRiseRise",
+ "SiS SiS SiS ",
+ "UMC UMC UMC ",
+ "VIA VIA VIA ",
+ "Vortex86 SoC",
+ "KVMKVMKVMKVM"
+};
+
+cputype_t get_cpu_type(void)
+{
+ static cputype_t cputype;
+ if (cputype == CT_NONE) {
+ union {
+ char buf[12];
+ uint32_t bufu32[3];
+ } u;
+ uint32_t i;
+
+ ___cpuid(CPU_VENDORID, &i, &u.bufu32[0], &u.bufu32[2], &u.bufu32[1]);
+ u.buf[12] = '\0';
+
+ for (i = 0; i < sizeof(cpuids) / sizeof(cpuids[0]); ++i) {
+ if (strncmp(cpuids[i], u.buf, 12) == 0) {
+ cputype = (cputype_t)i;
+ break;
+ }
+ }
+ }
+
+ return cputype;
+}
+
+const char *get_cpu_type_string(const cputype_t cputype)
+{
+ return cpuids[(int)cputype];
+}
+