m1cpu: support for getting brand name
diff --git a/cpu.go b/cpu.go
index 5a5d9b3..2e1bf2a 100644
--- a/cpu.go
+++ b/cpu.go
@@ -19,6 +19,7 @@
// int global_eCoreL1DataCacheSize;
// int global_pCoreL2CacheSize;
// int global_eCoreL2CacheSize;
+// char global_brand[32];
//
// UInt64 getFrequency(CFTypeRef typeRef) {
// CFDataRef cfData = typeRef;
@@ -43,6 +44,11 @@
// return value;
// }
//
+// void sysctl_string(const char * name, char * dest) {
+// size_t size = 32;
+// sysctlbyname(name, dest, &size, NULL, 0);
+// }
+//
// void initialize() {
// global_pCoreCount = sysctl_int("hw.perflevel0.physicalcpu");
// global_eCoreCount = sysctl_int("hw.perflevel1.physicalcpu");
@@ -52,6 +58,7 @@
// global_eCoreL1DataCacheSize = sysctl_int("hw.perflevel1.l1dcachesize");
// global_pCoreL2CacheSize = sysctl_int("hw.perflevel0.l2cachesize");
// global_eCoreL2CacheSize = sysctl_int("hw.perflevel1.l2cachesize");
+// sysctl_string("machdep.cpu.brand_string", global_brand);
//
// CFMutableDictionaryRef matching = IOServiceMatching("AppleARMIODevice");
// io_iterator_t iter;
@@ -125,6 +132,10 @@
// int eCoreL2CacheSize() {
// return global_eCoreL2CacheSize;
// }
+//
+// char * modelName() {
+// return global_brand;
+// }
import "C"
func init() {
@@ -189,3 +200,7 @@
int(C.eCoreL1DataCacheSize()),
int(C.eCoreL2CacheSize())
}
+
+func ModelName() string {
+ return C.GoString(C.modelName())
+}
diff --git a/cpu_test.go b/cpu_test.go
index 704d13a..ed38452 100644
--- a/cpu_test.go
+++ b/cpu_test.go
@@ -39,6 +39,7 @@
}
func Test_Show(t *testing.T) {
+ t.Log("model name", ModelName())
t.Log("pCore Hz", PCoreHz())
t.Log("eCore Hz", ECoreHz())
t.Log("pCore GHz", PCoreGHz())