1
0
mirror of https://gitlab.com/80486DX2-66/gists synced 2025-04-19 17:49:05 +05:30

cpuid_vendor_id.mod.c: don't waste 1 char for convenience

This commit is contained in:
パチュリー・ノーレッジ 2025-03-09 14:10:17 +03:00
parent 3a31367749
commit b45d4a865e
Signed by: 80486DX2-66
GPG Key ID: 83631EF27054609B

View File

@ -58,7 +58,7 @@ static inline void native_cpuid(unsigned int function_id, cpuid_t r) {
#endif
}
#define VENDOR_ID_LEN 13
#define VENDOR_ID_LEN 12
/*
* FIXME: you have to make sure the vendor argument is at least lengthed
@ -74,12 +74,13 @@ static inline void cpuid_vendor_id(char vendor[VENDOR_ID_LEN]) {
((unsigned*) vendor)[0] = v[EBX];
((unsigned*) vendor)[1] = v[EDX];
((unsigned*) vendor)[2] = v[ECX];
vendor[VENDOR_ID_LEN - 1] = '\0';
}
int main(void) {
char vendor_string[VENDOR_ID_LEN];
cpuid_vendor_id(vendor_string);
printf("CPU Vendor ID: '%s'\n", vendor_string);
fputs("CPU Vendor ID: '", stdout);
fwrite(vendor_string, sizeof(char), 12, stdout);
fputs("'\n", stdout);
return 0;
}