3 #include <sys/sysctl.h>
6 #elif defined(__x86_64__)
7 #if defined(HAVE_CPUID_H)
22 #if defined(__APPLE__)
23 sysctlbyname(
"machdep.cpu.brand_string", name, &len, NULL, 0);
24 #elif defined(__x86_64__) && defined(HAVE_CPUID_H)
26 __get_cpuid(0x80000002, brand+0x0, brand+0x1, brand+0x2, brand+0x3);
27 __get_cpuid(0x80000003, brand+0x4, brand+0x5, brand+0x6, brand+0x7);
28 __get_cpuid(0x80000004, brand+0x8, brand+0x9, brand+0xa, brand+0xb);
29 strncpy(name, (
char *) brand, len);
30 #elif defined(_ARCH_PPC64) || defined(__aarch64__)
31 FILE *fp = fopen(
"/proc/cpuinfo",
"r");
33 const char *delim =
":\n";
34 #if defined(__aarch64__)
36 strncpy(name,
"ARM", len);
41 #if defined(_ARCH_PPC64)
42 if(strstr(
buf,
"cpu")) {
43 char *token = strtok (
buf, delim);
44 token = strtok (NULL, delim);
45 strncpy(name, token+1, len);
48 #elif defined(__aarch64__)
49 if (strstr(
buf,
"CPU implementer")) {
50 char *token = strtok (
buf, delim);
51 token = strtok (NULL, delim);
52 if (strstr(token,
"0x46")) {
56 else if(strstr(token,
"0x41")) {
62 if (strstr(
buf,
"CPU part") && cpufj) {
63 char *token = strtok (
buf, delim);
64 token = strtok (NULL, delim);
65 if (strstr(token,
"0x001")) {
66 strncpy(name,
"Fujitsu A64FX", len);
71 if (strstr(
buf,
"CPU part") && cpuarm) {
72 char *token = strtok (
buf, delim);
73 token = strtok (NULL, delim);
74 if (strstr(token,
"0xd4f")) {
75 strncpy(name,
"ARM Neoverse V2", len);
83 strncpy(name,
"Unknown CPU", len);
void system_cpuid(char *name, size_t len)