From 7eb5bd4eca2ff12d0fe4388704062ac0bf61ed2c Mon Sep 17 00:00:00 2001 From: Uros Bizjak Date: Wed, 3 May 2017 22:00:50 +0200 Subject: [PATCH] backport: re PR target/68491 (libgcc calls __get_cpuid with 0 level breaks on early 486) Backport from mainline 2017-05-01 Uros Bizjak PR target/68491 * config/i386/cpuid.h (__get_cpuid): Always return 0 when __get_cpuid_max returns 0. From-SVN: r247566 --- gcc/ChangeLog | 9 +++++++++ gcc/config/i386/cpuid.h | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b592996003ce..fa4ed943ddc9 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2017-05-03 Uros Bizjak + + Backport from mainline + 2017-05-01 Uros Bizjak + + PR target/68491 + * config/i386/cpuid.h (__get_cpuid): Always return 0 when + __get_cpuid_max returns 0. + 2017-04-21 Christophe Lyon Backport from mainline diff --git a/gcc/config/i386/cpuid.h b/gcc/config/i386/cpuid.h index 1ddc6e2e6a87..c7778d989f56 100644 --- a/gcc/config/i386/cpuid.h +++ b/gcc/config/i386/cpuid.h @@ -234,8 +234,9 @@ __get_cpuid (unsigned int __level, 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); -- 2.47.2