Mail Archives: cygwin/2002/03/06/01:41:36
On Tuesday 05 March 2002 17:55, soren_andersen AT fastmail DOT fm wrote:
> Hello,
>
> I was just wondering if there is any existing code that's perhaps part of
> the Cygwin "code base" or else known to some readers, that will allow
> querying of the CPU type?
>
> I'd like to have a pretty simple way to get this. One application would be
> an enhanced "configure" for zlib-1.1.3 which would place the appropriate
> assembler source for a 486, a 586 or a 686 -- for example -- into the
> Makefile build formulae. I need only the "generation" of chip, i.e. what
> Intel calls the "Family."
>
> I am thinking that maybe somebody already worked this out. I am also
> thinking that instead, maybe the way this is done is in assembler and if so
> maybe it hasn't been done (specific to Cygwin, that is; I have found a
> couple of free utilities out there that do this from a command line). I am
> just full of semi-educated guesses ;-).
>
It's not OS-specific. Any gcc code which does what you want should work, or
you could translate MS-style asm() syntax, as I did here:
#include <windows.h>
#define FAMILY_ID 0x0f00 // EAX[11:8] - Bit 11 thru 8 contains family
unsigned int reg_eax = 0;
unsigned int reg_edx = 0;
unsigned int junk, junk1;
unsigned int vendor_id[3] = {0, 0, 0};
__try { // verify cpuid instruction is supported
__asm__("cpuid" : "=a" (reg_eax), "=b" (*vendor_id),
"=c" (vendor_id[2]), "=d" (vendor_id[1]) : "a" (0));
__asm__("cpuid" : "=a" (reg_eax), "=b"(junk), "=c"(junk1),
"=d" (reg_edx) : "a" (1));
// eax contains cpu family type info
// edx has info whether Hyper-Threading
// Technology is available
}
__except (EXCEPTION_EXECUTE_HANDLER ) {
return NO_CPUID; // CPUID is not supported and so
// it is not a recent family CPU
}
return (reg_eax & FAMILY_ID);
>
> Regards,
> Soren Andersen
--
Tim Prince
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
- Raw text -