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

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

 




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 :


fs$ grep -E "^mod|^ven|fam" /proc/cpuinfo | sort -u
cpu family      : 6
model           : 94
model name      : Intel(R) Pentium(R) CPU G4500 @ 3.50GHz
vendor_id       : GenuineIntel
fs$
fs$ /usr/bin/gcc --version
gcc (Debian 7.3.0-24) 7.3.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

fs$ /usr/bin/gcc -m64 -g -std=iso9899:1999 -pedantic -pedantic-errors -o detect_cpu detect_cpu.c

fs$ ./detect_cpu
Intel CPU.
 NOT Intel Atom CPU.
 NOT Intel Core 2 CPU.
Intel Core i7 CPU.
 NOT Intel Core i7 Nehalem CPU.
 NOT Intel Core i7 Westmere CPU.
 NOT Intel Core i7 Sandy Bridge CPU.
 NOT AMD CPU.
 NOT AMD Family 10h CPU.
 NOT AMD Family 10h Barcelona CPU.
 NOT AMD Family 10h Shanghai CPU.
 NOT AMD Family 10h Istanbul CPU.
 NOT AMD Family 14h CPU.
 NOT AMD Family 15h CPU.
 NOT AMD Family 15h Bulldozer version 1.
 NOT AMD Family 15h Bulldozer version 2.
 NOT AMD Family 15h Bulldozer version 3.
 NOT AMD Family 15h Bulldozer version 4.
 NOT AMD Family 16h CPU.
 NOT AMD Family 17h CPU.
 NOT AMD Family 17h Zen version 1.
fs$

This is really NOT a Core i7 at all.

Is there something missing ?


Dennis



[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