Skip to content

Instantly share code, notes, and snippets.

@YoshitakaMo
Last active August 3, 2024 15:40
Show Gist options
  • Save YoshitakaMo/eb6e6df7a621a9c9737bcc9363cf9bfc to your computer and use it in GitHub Desktop.
Save YoshitakaMo/eb6e6df7a621a9c9737bcc9363cf9bfc to your computer and use it in GitHub Desktop.
fastmap.patch
diff --git a/src/fastmap.cpp b/src/fastmap.cpp
index 3a7e62e..d0ce8a7 100644
--- a/src/fastmap.cpp
+++ b/src/fastmap.cpp
@@ -49,13 +49,30 @@ extern uint64_t tprof[LIM_R][LIM_C];
// ---------------
void __cpuid(unsigned int i, unsigned int cpuid[4]) {
-#ifdef _WIN32
- __cpuid((int *) cpuid, (int)i);
-
+#if defined(_WIN32) || (defined(__x86_64__) || defined(__i386__))
+ #ifdef _WIN32
+ __cpuid((int *) cpuid, (int)i);
+ #else
+ asm volatile (
+ "cpuid"
+ : "=a" (cpuid[0]), "=b" (cpuid[1]), "=c" (cpuid[2]), "=d" (cpuid[3])
+ : "a" (i), "c" (0)
+ );
+ #endif
#else
- asm volatile
- ("cpuid" : "=a" (cpuid[0]), "=b" (cpuid[1]), "=c" (cpuid[2]), "=d" (cpuid[3])
- : "0" (i), "2" (0));
+ cpuid[0] = cpuid[1] = cpuid[2] = cpuid[3] = 0;
+
+ switch(i) {
+ case 0:
+ cpuid[0] = 0;
+ break;
+ case 1:
+ cpuid[0] = 0;
+ cpuid[1] = 0;
+ cpuid[2] = (1 << 9);
+ cpuid[3] = (1 << 25) | (1 << 26);
+ break;
+ }
#endif
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment