Re: question about "x86 Built-in Functions" to detect cpu type

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

 



On 2018-07-08 12:46 -0400, Dennis Clarke wrote:
> On 07/08/2018 12:36 PM, U.Mutlu wrote:
> > Dennis Clarke wrote on 07/08/2018 03:44 PM:
> > > 
> > > As seen at :
> > > 
> > >      https://gcc.gnu.org/onlinedocs/gcc/x86-Built-in-Functions.html
> > > 
> > > 
> > > The example there seems to suggest that I could do this :
> > > 
> > > 
> > >      __builtin_cpu_init ();
> > >      if ( __builtin_cpu_is ("corei7") ){
> > >          fprintf ( stdout, "Intel Core i7 CPU.       \n" );
> > >      } else {
> > >          fprintf ( stdout, " NOT Intel Core i7 CPU.       \n" );
> > >      }
> > > 
> > > 
> > > However I get an odd result from my Debian machine here when I try to
> > > check for every possible option :
> > 
> > Just guessing: are you maybe calling __builtin_cpu_init() multiple times?
> > Though it shouldn't make a difference, IMO.
> 
> Tried that once before calling "__builtin_cpu_is" and also tried it
>   every time and it makes no difference.

GCC actually "think" Pentium G and Core i3/i5 are Core i7 because they support
instructions of Core i7.
-- 
Xi Ruoyao <ryxi@xxxxxxxxxxxxxxxxx>
School of Aerospace Science and Technology, Xidian University



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux