From 09b4830ba6a41b4fbe2e42b51721a00f2b13c1e3 Mon Sep 17 00:00:00 2001 From: lizy <821610729@qq.com> Date: Wed, 28 Aug 2024 09:24:06 +0800 Subject: [PATCH] add Hygon Dhyana support #129 --- go_bindings/Sigar/src/os/win32/win32_sigar.c | 2 ++ src/os/linux/linux_sigar.c | 3 +++ src/os/win32/win32_sigar.c | 3 +++ src/sigar_util.c | 3 ++- 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/go_bindings/Sigar/src/os/win32/win32_sigar.c b/go_bindings/Sigar/src/os/win32/win32_sigar.c index b79ee2076..3fb19696b 100644 --- a/go_bindings/Sigar/src/os/win32/win32_sigar.c +++ b/go_bindings/Sigar/src/os/win32/win32_sigar.c @@ -2214,6 +2214,8 @@ static int sigar_cpu_info_get(sigar_t *sigar, sigar_cpu_info_t *info) else { if (strEQ(info->vendor, "AuthenticAMD")) { SIGAR_SSTRCPY(info->vendor, "AMD"); + } else if (strEQ(info->vendor, "HygonGenuine")) { + SIGAR_SSTRCPY(info->vendor, "Hygon"); } } diff --git a/src/os/linux/linux_sigar.c b/src/os/linux/linux_sigar.c index 905bcfc50..54f5d6039 100644 --- a/src/os/linux/linux_sigar.c +++ b/src/os/linux/linux_sigar.c @@ -1565,6 +1565,9 @@ static int get_cpu_info(sigar_t *sigar, sigar_cpu_info_t *info, else if (strEQ(info->vendor, "AuthenticAMD")) { SIGAR_SSTRCPY(info->vendor, "AMD"); } + else if (strEQ(info->vendor, "HygonGenuine")) { + SIGAR_SSTRCPY(info->vendor, "Hygon"); + } } break; case 'f': diff --git a/src/os/win32/win32_sigar.c b/src/os/win32/win32_sigar.c index 5b1e2ea13..d6ca67361 100755 --- a/src/os/win32/win32_sigar.c +++ b/src/os/win32/win32_sigar.c @@ -2282,6 +2282,9 @@ static int sigar_cpu_info_get(sigar_t *sigar, sigar_cpu_info_t *info) if (strEQ(info->vendor, "AuthenticAMD")) { SIGAR_SSTRCPY(info->vendor, "AMD"); } + else if (strEQ(info->vendor, "HygonGenuine")) { + SIGAR_SSTRCPY(info->vendor, "Hygon"); + } } size = sizeof(info->model); diff --git a/src/sigar_util.c b/src/sigar_util.c index 325b65ada..226089833 100644 --- a/src/sigar_util.c +++ b/src/sigar_util.c @@ -554,6 +554,7 @@ static void sigar_cpuid(sigar_uint32_t request, #define INTEL_ID 0x756e6547 #define AMD_ID 0x68747541 +#define HYGON_ID 0x6f677948 int sigar_cpu_core_count(sigar_t *sigar) { @@ -565,7 +566,7 @@ int sigar_cpu_core_count(sigar_t *sigar) sigar_cpuid(0, &id); - if ((id.ebx == INTEL_ID) || (id.ebx == AMD_ID)) { + if ((id.ebx == INTEL_ID) || (id.ebx == AMD_ID) || (id.ebx == HYGON_ID)) { sigar_cpuid(1, &id); if (id.edx & (1<<28)) {