From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 109555 invoked by alias); 7 Oct 2019 19:55:15 -0000 Mailing-List: contact cygwin-cvs-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: cygwin-cvs-owner@cygwin.com Received: (qmail 109538 invoked by uid 9996); 7 Oct 2019 19:55:15 -0000 Date: Mon, 07 Oct 2019 19:55:00 -0000 Message-ID: <20191007195515.109537.qmail@sourceware.org> Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Ken Brown To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] fhandler_proc.cc(format_proc_cpuinfo): fix cpuid level count X-Act-Checkin: newlib-cygwin X-Git-Author: Brian Inglis X-Git-Refname: refs/heads/master X-Git-Oldrev: acc8849f844f2dbc41ef8da9687bbe1c1d5b3bdc X-Git-Newrev: 74aa6e3cdb167bdbfa02d5781e9efb154a15bcdb X-SW-Source: 2019-q4/txt/msg00002.txt.bz2 https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=74aa6e3cdb167bdbfa02d5781e9efb154a15bcdb commit 74aa6e3cdb167bdbfa02d5781e9efb154a15bcdb Author: Brian Inglis Date: Mon Oct 7 10:22:59 2019 -0600 fhandler_proc.cc(format_proc_cpuinfo): fix cpuid level count Fix cpuid level count as number of non-zero leafs excluding sub-leafs. Diff: --- winsup/cygwin/fhandler_proc.cc | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) 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");