delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/03/06/01:41:36

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
From: Tim Prince <tprince AT computer DOT org>
Reply-To: tprince AT computer DOT org
To: soren_andersen AT fastmail DOT fm, cygwin AT cygwin DOT com
Subject: Re: Any existing routine for CPU-id on Cygwin?
Date: Tue, 5 Mar 2002 22:34:37 -0800
X-Mailer: KMail [version 1.3.1]
References: <3C8530B1 DOT 6976 DOT 7914364 AT localhost>
In-Reply-To: <3C8530B1.6976.7914364@localhost>
MIME-Version: 1.0
Message-Id: <20020306063437.EEA8E2CD4A@inet1.ywave.com>

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019