diff options
author | Brian Inglis <Brian.Inglis@SystematicSW.ab.ca> | 2019-10-07 10:22:59 -0600 |
---|---|---|
committer | Ken Brown <kbrown@cornell.edu> | 2019-10-07 15:50:32 -0400 |
commit | 74aa6e3cdb167bdbfa02d5781e9efb154a15bcdb (patch) | |
tree | 05761f0a1cf18b99b0e67298c8af8e773ce53704 | |
parent | acc8849f844f2dbc41ef8da9687bbe1c1d5b3bdc (diff) | |
download | newlib-74aa6e3cdb167bdbfa02d5781e9efb154a15bcdb.zip newlib-74aa6e3cdb167bdbfa02d5781e9efb154a15bcdb.tar.gz newlib-74aa6e3cdb167bdbfa02d5781e9efb154a15bcdb.tar.bz2 |
fhandler_proc.cc(format_proc_cpuinfo): fix cpuid level count
Fix cpuid level count as number of non-zero leafs excluding sub-leafs.
-rw-r--r-- | winsup/cygwin/fhandler_proc.cc | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/winsup/cygwin/fhandler_proc.cc b/winsup/cygwin/fhandler_proc.cc index 13cc368..78518ba 100644 --- a/winsup/cygwin/fhandler_proc.cc +++ b/winsup/cygwin/fhandler_proc.cc @@ -927,13 +927,30 @@ format_proc_cpuinfo (void *, char *&destbuf) } + /* level is number of non-zero leafs exc. sub-leafs */ + int level = maxf + 1 + (maxe & 0x7fffffff) + 1; + + for (uint32_t l = maxe; 0x80000001 < l; --l) + { + uint32_t a, b, c, d; + cpuid (&a, &b, &c, &d, l); + if (!(a | b | c | d)) --level; + } + + for (uint32_t l = maxf; 1 < l; --l) + { + uint32_t a, b, c, d; + cpuid (&a, &b, &c, &d, l); + if (!(a | b | c | d)) --level; + } + bufptr += __small_sprintf (bufptr, "fpu\t\t: %s\n" "fpu_exception\t: %s\n" "cpuid level\t: %d\n" "wp\t\t: yes\n", (features1 & (1 << 0)) ? "yes" : "no", (features1 & (1 << 0)) ? "yes" : "no", - maxf); + level); print ("flags\t\t:"); if (features1 & (1 << 0)) print (" fpu"); |