From 7ac08e73e222980781fb8554ccea0c9dd462def0 Mon Sep 17 00:00:00 2001 From: Stas Degteff Date: Thu, 13 Oct 2005 19:28:32 +0000 Subject: [PATCH] CPUID support in GNU C --- docs/notework.txt | 8 +++++--- goldlib/gall/gutlvers.cpp | 37 ++++++++++++++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/docs/notework.txt b/docs/notework.txt index 91142f9..27b9710 100644 --- a/docs/notework.txt +++ b/docs/notework.txt @@ -10,10 +10,12 @@ ______________________________________________________________________ Notes for GoldED+ 1.1.5, /snapshot/ ______________________________________________________________________ -! Added gnwin and rddtwin project files in MSVC6 workspace. ++ CPUID support for GNU C builds. -+ Added LocationDelimiter "delim" config file token that separate - city names in netmail areas. +! GNwin and RDDTwin project files is added into MSVC6 workspace. + ++ LocationDelimiter config file token to specify separating char + between city names in netmail areas. + LocationAlias is case insensitive now. diff --git a/goldlib/gall/gutlvers.cpp b/goldlib/gall/gutlvers.cpp index 201caf1..4043aca 100644 --- a/goldlib/gall/gutlvers.cpp +++ b/goldlib/gall/gutlvers.cpp @@ -78,6 +78,8 @@ static bool HaveCPUID() return false; } + return true; +#elif defined(__GNUC__) return true; #else return false; @@ -225,7 +227,7 @@ static void cpuname(int family, int model, const char *v_name, char *m_name) else if (!strcmp("CentaurHauls", v_name)) sprintf(m_name, "CenF%dM%d", family, model); else - sprintf(m_name, "%3sF%dM%d", v_name, family, model); + sprintf(m_name, "CPU %3sF%dM%d", v_name, family, model); } @@ -263,6 +265,39 @@ void gcpuid(gcpu_info *pinfo) cpuid mov standard, eax } +#elif defined(__GNUC__) + + { +// dword _cpu,_cpu_id=0, _cpu_high; +// dword CPU_ID asm("_cpu_id") =0; +// char CPU_VENDOR[sizeof(dword)*3+1] asm("_cpu_vendor"); +// char _cpu_feature[20]; +// +// memset(CPU_VENDOR,0,sizeof(CPU_VENDOR)); +// memset(_cpu_feature,0,sizeof(_cpu_feature)); + + asm ( + "xor %%eax, %%eax \n\t" + "cpuid \n\t" + "movl %%ebx, %0 \n\t" + "movl %%edx, %1 \n\t" + "movl %%ecx, %2" + : "=m" (vendor.dw.dw0), "=m" (vendor.dw.dw1), "=m" (vendor.dw.dw2) + : + : "eax", "ebx", "ecx", "edx" + ); + + asm ( + "movl $1, %%eax \n\t" + "cpuid \n\t" + "movl %%eax,%0 " + : "=g" (standard) + : + : "eax" + ); +// strncpy(vendor.buff,(const char*)CPU_VENDOR,_MAX_VNAME_LEN); +// standard = CPU_ID; + } #else strcpy(vendor.buff, "UNKNOUN_CPU!"); #endif