Skip to content

Commit

Permalink
Address review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Wunkolo committed Sep 6, 2024
1 parent 5a1165c commit eeda3aa
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 16 deletions.
18 changes: 5 additions & 13 deletions src/arm/midr.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ bool read_registry_hklm_int(char* path, char* name, void* value, bool is64) {
bool get_win32_core_info_int(uint32_t core_index, char* name, void* value, bool is64) {
// path + digits
uint32_t max_path_size = 45+3+1;
char* path = emalloc(sizeof(char) * max_path_size);
char* path = ecalloc(sizeof(char) * max_path_size, sizeof(char));
snprintf(path, max_path_size, "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\%u", core_index);
return read_registry_hklm_int(path, name, value, is64);
}
Expand Down Expand Up @@ -275,20 +275,12 @@ struct features* get_features_info(void) {
printWarn("Unable to retrieve PFR0 via registry");
}
else {

// FP and AdvSimd are signed. "-1" is the only value that indicates
// the feature is not available

// FP[19:16]
// 0: Float support
// 1: Float support + FP16
int8_t fp = ((int64_t)(pfr0 << (60 - 16)) >> 60);

// AdvSimd[23:20]
// 0: AdvSimd support
// 1: AdvSimd support + FP16
// -1: Not available
// 0: AdvSimd support
// 1: AdvSimd support + FP16
int8_t adv_simd = ((int64_t)(pfr0 << (60 - 20)) >> 60);
feat->NEON = (adv_simd >= 0) && (fp >= 0);
feat->NEON = (adv_simd >= 0);

// SVE[35:32]
feat->SVE = (pfr0 >> 32) & 0xF ? true : false;
Expand Down
7 changes: 6 additions & 1 deletion src/arm/soc.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,16 @@
#define NOMINMAX
#include <windows.h>

// Gets a RRF_RT_REG_SZ-entry from the Windows registry, returning a newly allocated
// string and its length
bool read_registry_hklm_sz(char* path, char* value, char** string, LPDWORD length) {
// First call to RegGetValueA gets the length of the string and determines how much
// memory should be allocated for the new string
if(RegGetValueA(HKEY_LOCAL_MACHINE, path, value, RRF_RT_REG_SZ, NULL, NULL, length) != ERROR_SUCCESS) {
return false;
}
*string = emalloc(*length);
*string = ecalloc(*length, sizeof(char));
// Second call actually writes the string data
if(RegGetValueA(HKEY_LOCAL_MACHINE, path, value, RRF_RT_REG_SZ, NULL, *string, length) != ERROR_SUCCESS) {
return false;
}
Expand Down
1 change: 1 addition & 0 deletions src/common/printer.c
Original file line number Diff line number Diff line change
Expand Up @@ -887,6 +887,7 @@ bool print_cpufetch_arm(struct cpuInfo* cpu, STYLE s, struct color** cs, struct
setAttribute(art, ATTRIBUTE_SOC, soc_name);

// Currently no reliable way to identify the specific SoC on Windows
// https://github.com/Dr-Noob/cpufetch/pull/273
// Hide manufacturing process
#if !defined(_WIN32)
setAttribute(art, ATTRIBUTE_TECHNOLOGY, manufacturing_process);
Expand Down
6 changes: 4 additions & 2 deletions src/common/soc.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,17 @@ void fill_soc(struct system_on_chip* soc, char* soc_name, SOC soc_model, int32_t
}
}

#ifdef _WIN32
VENDOR try_match_soc_vendor_name(char* vendor_name)
{
for(size_t i=0; i < sizeof(soc_trademark_string)/sizeof(soc_trademark_string[0]); i++) {
if(soc_trademark_string[i] && strstr(vendor_name, soc_trademark_string[i]) != NULL) {
for(size_t i=1; i < sizeof(soc_trademark_string)/sizeof(soc_trademark_string[0]); i++) {
if(strstr(vendor_name, soc_trademark_string[i]) != NULL) {
return i;
}
}
return SOC_VENDOR_UNKNOWN;
}
#endif

bool match_soc(struct system_on_chip* soc, char* raw_name, char* expected_name, char* soc_name, SOC soc_model, int32_t process) {
int len1 = strlen(raw_name);
Expand Down
2 changes: 2 additions & 0 deletions src/common/soc.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ VENDOR get_soc_vendor(struct system_on_chip* soc);
bool match_soc(struct system_on_chip* soc, char* raw_name, char* expected_name, char* soc_name, SOC soc_model, int32_t process);
char* get_str_process(struct system_on_chip* soc);
void fill_soc(struct system_on_chip* soc, char* soc_name, SOC soc_model, int32_t process);
#ifdef _WIN32
VENDOR try_match_soc_vendor_name(char* vendor_name);
#endif

#define SOC_START if (false) {}
#define SOC_EQ(raw_name, expected_name, soc_name, soc_model, soc, process) \
Expand Down

0 comments on commit eeda3aa

Please sign in to comment.