1
0
Fork 0
mirror of https://github.com/anrieff/libcpuid synced 2024-12-16 16:35:45 +00:00

check-consistency: fix processor definitions checks

Processor definitions checks were not working due to old harcoded values.
The tool pointed a typo in codename for "Athlon 64 (Sherman/512K)".
This commit is contained in:
The Tumultuous Unicorn Of Darkness 2024-06-23 20:02:06 +02:00
parent 1ac6898da0
commit 0dae8b8d92
No known key found for this signature in database
GPG key ID: 1E55EE2EFF18BC1A
3 changed files with 13 additions and 6 deletions

View file

@ -147,6 +147,9 @@ cache_exp = re.compile(".*([\(/ ][0-9]+K).*")
# Check whether CPU codenames for consistency:
# - Codenames should not exceed 31 characters
# - Check for common typos
definitions = 0
match_entry_fields = 12 # this number needs to change if the definition of match_entry_t ever changes
codename_str_max = 64-1 # this number needs to change if the value of CODENAME_STR_MAX ever changes
common_cache_sizes = ["8", "16", "32", "64", "128", "256", "512", "1024", "2048", "3072", "4096", "6144", "8192", "12288", "16384"]
for fn in glob.glob("%s/*.c" % sys.argv[1]):
bfn = os.path.basename(fn)
@ -167,18 +170,18 @@ for fn in glob.glob("%s/*.c" % sys.argv[1]):
continue
inner = line[i+1:j]
parts = inner.split(",")
if len(parts) == 11: #this number needs to change if the definition of match_entry_t ever changes
if len(parts) == match_entry_fields:
cdefs += 1
s = parts[10].strip()
s = parts[match_entry_fields-1].strip()
if s[0] != '"' or s[-1] != '"':
err += 1
print("..Warning, %s:%d - cannot correctly handle the cpu codename" % (bfn, nline))
allok = False
continue
s = s[1:-1]
if len(s) > 31:
if len(s) > codename_str_max:
err += 1
print("..%s:%d - codename (%s) is longer than 31 characters!" % (bfn, nline, s))
print("..%s:%d - codename (%s) is longer than %d characters!" % (bfn, nline, s, codename_str_max))
allok = False
if cache_exp.match(s):
cache_size = cache_exp.findall(s)[0][1:-1]
@ -187,11 +190,15 @@ for fn in glob.glob("%s/*.c" % sys.argv[1]):
print("..Warning, %s:%d - suspicious cache size in codename [%s] (%s)" % (bfn, nline, s, cache_size))
allok = False
if cdefs:
definitions += 1
print(" %s: %d processor definitions," % (bfn, cdefs), end=' ')
if allok:
print("all OK")
else:
print("some errors/warnings")
f.close()
if definitions == 0:
err += 1
print("..Warning, no processor definitions found")
sys.exit(err)

View file

@ -176,7 +176,7 @@ const struct match_entry_t cpudb_amd[] = {
{ 15, -1, -1, 15, 0x5f, 1, 256, -1, NC, SEMPRON_ , 0, "Sempron 64 (Manila/256K)" },
{ 15, -1, -1, 15, 0x6b, 2, 256, -1, NC, SEMPRON_ , 0, "Sempron 64 Dual (Sherman/256K)"},
{ 15, -1, -1, 15, 0x6b, 2, 512, -1, NC, SEMPRON_ , 0, "Sempron 64 Dual (Sherman/512K)"},
{ 15, -1, -1, 15, 0x7c, 1, 512, -1, NC, ATHLON_ , 0, "Athlon 64 (Sherman/515K)" },
{ 15, -1, -1, 15, 0x7c, 1, 512, -1, NC, ATHLON_ , 0, "Athlon 64 (Sherman/512K)" },
{ 15, -1, -1, 15, 0x7f, 1, 256, -1, NC, SEMPRON_ , 0, "Sempron 64 (Sparta/256K)" },
{ 15, -1, -1, 15, 0x7f, 1, 512, -1, NC, SEMPRON_ , 0, "Sempron 64 (Sparta/512K)" },
{ 15, -1, -1, 15, 0x4c, 1, 256, -1, NC, MOBILE_| SEMPRON_ , 0, "Mobile Sempron 64 (Keene/256K)"},

View file

@ -110,5 +110,5 @@ general
-1
-1
64 (non-authoritative)
Athlon 64 (Sherman/515K)
Athlon 64 (Sherman/512K)
fpu vme de pse tsc msr pae mce cx8 apic mtrr sep pge mca cmov pat pse36 clflush mmx fxsr sse sse2 pni cx16 syscall mmxext 3dnow 3dnowext nx fxsr_opt rdtscp lm lahf_lm svm 3dnowprefetch ts fid vid ttp tm_amd stc 100mhzsteps