Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/gpl3/gcc.old/dist/gcc/config/i386 Fix logic bug whe...



details:   https://anonhg.NetBSD.org/src/rev/7bbe2cf3e6f1
branches:  trunk
changeset: 341801:7bbe2cf3e6f1
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Nov 22 20:47:42 2015 +0000

description:
Fix logic bug where __cpuid gets called when __get_cpuid_max() returns 0.
This happens when __level == 0, from libgcc/config/i386/cpuinfo.c#285.
This breaks early i486 CPUs which don't have cpuid

diffstat:

 external/gpl3/gcc.old/dist/gcc/config/i386/cpuid.h |  3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diffs (14 lines):

diff -r 940a0e137b8f -r 7bbe2cf3e6f1 external/gpl3/gcc.old/dist/gcc/config/i386/cpuid.h
--- a/external/gpl3/gcc.old/dist/gcc/config/i386/cpuid.h        Sun Nov 22 20:47:05 2015 +0000
+++ b/external/gpl3/gcc.old/dist/gcc/config/i386/cpuid.h        Sun Nov 22 20:47:42 2015 +0000
@@ -259,8 +259,9 @@
             unsigned int *__ecx, unsigned int *__edx)
 {
   unsigned int __ext = __level & 0x80000000;
+  unsigned int __maxlevel = __get_cpuid_max (__ext, 0);
 
-  if (__get_cpuid_max (__ext, 0) < __level)
+  if (__maxlevel == 0 || __maxlevel < __level)
     return 0;
 
   __cpuid (__level, *__eax, *__ebx, *__ecx, *__edx);



Home | Main Index | Thread Index | Old Index