Merge pull request #3397 from martin-frbg/m1detect
Fix detection of Apple M1 "Vortex"
This commit is contained in:
commit
2b28b88cab
|
@ -26,10 +26,12 @@
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#ifdef OS_DARWIN
|
#ifdef __APPLE__
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
int32_t value;
|
int32_t value;
|
||||||
size_t length=sizeof(value);
|
size_t length=sizeof(value);
|
||||||
|
int64_t value64;
|
||||||
|
size_t length64=sizeof(value64);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define CPU_UNKNOWN 0
|
#define CPU_UNKNOWN 0
|
||||||
|
@ -212,9 +214,9 @@ int detect(void)
|
||||||
|
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#ifdef DARWIN
|
#ifdef __APPLE__
|
||||||
sysctlbyname("hw.cpufamily",&value,&length,NULL,0);
|
sysctlbyname("hw.cpufamily",&value,&length,NULL,0);
|
||||||
if (value ==131287967) return CPU_VORTEX;
|
if (value ==131287967|| value == 458787763 ) return CPU_VORTEX;
|
||||||
#endif
|
#endif
|
||||||
return CPU_ARMV8;
|
return CPU_ARMV8;
|
||||||
#endif
|
#endif
|
||||||
|
@ -265,7 +267,7 @@ int n=0;
|
||||||
|
|
||||||
printf("#define NUM_CORES %d\n",n);
|
printf("#define NUM_CORES %d\n",n);
|
||||||
#endif
|
#endif
|
||||||
#ifdef DARWIN
|
#ifdef __APPLE__
|
||||||
sysctlbyname("hw.physicalcpu_max",&value,&length,NULL,0);
|
sysctlbyname("hw.physicalcpu_max",&value,&length,NULL,0);
|
||||||
printf("#define NUM_CORES %d\n",value);
|
printf("#define NUM_CORES %d\n",value);
|
||||||
#endif
|
#endif
|
||||||
|
@ -420,17 +422,19 @@ void get_cpuconfig(void)
|
||||||
printf("#define DTB_DEFAULT_ENTRIES 64 \n");
|
printf("#define DTB_DEFAULT_ENTRIES 64 \n");
|
||||||
printf("#define DTB_SIZE 4096 \n");
|
printf("#define DTB_SIZE 4096 \n");
|
||||||
break;
|
break;
|
||||||
#ifdef DARWIN
|
#ifdef __APPLE__
|
||||||
case CPU_VORTEX:
|
case CPU_VORTEX:
|
||||||
printf("#define VORTEX \n");
|
printf("#define VORTEX \n");
|
||||||
sysctlbyname("hw.l1icachesize",&value,&length,NULL,0);
|
sysctlbyname("hw.l1icachesize",&value64,&length64,NULL,0);
|
||||||
printf("#define L1_CODE_SIZE %d \n",value);
|
printf("#define L1_CODE_SIZE %lld \n",value64);
|
||||||
sysctlbyname("hw.cachelinesize",&value,&length,NULL,0);
|
sysctlbyname("hw.cachelinesize",&value64,&length64,NULL,0);
|
||||||
printf("#define L1_CODE_LINESIZE %d \n",value);
|
printf("#define L1_CODE_LINESIZE %lld \n",value64);
|
||||||
sysctlbyname("hw.l1dcachesize",&value,&length,NULL,0);
|
sysctlbyname("hw.l1dcachesize",&value64,&length64,NULL,0);
|
||||||
printf("#define L1_DATA_SIZE %d \n",value);
|
printf("#define L1_DATA_SIZE %lld \n",value64);
|
||||||
sysctlbyname("hw.l2dcachesize",&value,&length,NULL,0);
|
sysctlbyname("hw.l2cachesize",&value64,&length64,NULL,0);
|
||||||
printf("#define L2_SIZE %d \n",value);
|
printf("#define L2_SIZE %lld \n",value64);
|
||||||
|
printf("#define DTB_DEFAULT_ENTRIES 64 \n");
|
||||||
|
printf("#define DTB_SIZE 4096 \n");
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue