1
0
Fork 0
mirror of https://github.com/anrieff/libcpuid synced 2025-10-03 11:01:30 +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
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: # Check whether CPU codenames for consistency:
# - Codenames should not exceed 31 characters # - Codenames should not exceed 31 characters
# - Check for common typos # - 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"] 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]): for fn in glob.glob("%s/*.c" % sys.argv[1]):
bfn = os.path.basename(fn) bfn = os.path.basename(fn)
@ -167,18 +170,18 @@ for fn in glob.glob("%s/*.c" % sys.argv[1]):
continue continue
inner = line[i+1:j] inner = line[i+1:j]
parts = inner.split(",") 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 cdefs += 1
s = parts[10].strip() s = parts[match_entry_fields-1].strip()
if s[0] != '"' or s[-1] != '"': if s[0] != '"' or s[-1] != '"':
err += 1 err += 1
print("..Warning, %s:%d - cannot correctly handle the cpu codename" % (bfn, nline)) print("..Warning, %s:%d - cannot correctly handle the cpu codename" % (bfn, nline))
allok = False allok = False
continue continue
s = s[1:-1] s = s[1:-1]
if len(s) > 31: if len(s) > codename_str_max:
err += 1 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 allok = False
if cache_exp.match(s): if cache_exp.match(s):
cache_size = cache_exp.findall(s)[0][1:-1] 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)) print("..Warning, %s:%d - suspicious cache size in codename [%s] (%s)" % (bfn, nline, s, cache_size))
allok = False allok = False
if cdefs: if cdefs:
definitions += 1
print(" %s: %d processor definitions," % (bfn, cdefs), end=' ') print(" %s: %d processor definitions," % (bfn, cdefs), end=' ')
if allok: if allok:
print("all OK") print("all OK")
else: else:
print("some errors/warnings") print("some errors/warnings")
f.close() f.close()
if definitions == 0:
err += 1
print("..Warning, no processor definitions found")
sys.exit(err) 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, 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, 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, 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, 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, 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)"}, { 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
-1 -1
64 (non-authoritative) 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 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