Hans Leidekker : wbemprox: Add a function to retrieve the maximum processor clock speed.

Alexandre Julliard julliard at winehq.org
Thu Sep 6 13:37:23 CDT 2012


Module: wine
Branch: master
Commit: e2bd61b45d512229c200d91ce7afbefe790a37c5
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=e2bd61b45d512229c200d91ce7afbefe790a37c5

Author: Hans Leidekker <hans at codeweavers.com>
Date:   Thu Sep  6 14:03:38 2012 +0200

wbemprox: Add a function to retrieve the maximum processor clock speed.

---

 dlls/wbemprox/builtin.c |   17 +++++++++--------
 1 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/dlls/wbemprox/builtin.c b/dlls/wbemprox/builtin.c
index 4c82425..c2271c0 100644
--- a/dlls/wbemprox/builtin.c
+++ b/dlls/wbemprox/builtin.c
@@ -780,14 +780,19 @@ static void get_processor_name( WCHAR *name )
         regs_to_str( regs, 16, name + 32 );
     }
 }
+static UINT get_processor_maxclockspeed( void )
+{
+    PROCESSOR_POWER_INFORMATION info;
+    if (!NtPowerInformation( ProcessorInformation, NULL, 0, &info, sizeof(info) )) return info.MaxMhz;
+    return 1000000;
+}
 
 static void fill_processor( struct table *table )
 {
     static const WCHAR fmtW[] = {'C','P','U','%','u',0};
     WCHAR device_id[14], processor_id[17], manufacturer[13], name[49] = {0};
     struct record_processor *rec;
-    UINT i, offset = 0, num_logical_processors, count = get_processor_count(), cpuMhz;
-    PROCESSOR_POWER_INFORMATION ppi;
+    UINT i, offset = 0, maxclockspeed, num_logical_processors, count = get_processor_count();
 
     if (!(table->data = heap_alloc( sizeof(*rec) * count ))) return;
 
@@ -795,11 +800,7 @@ static void fill_processor( struct table *table )
     get_processor_manufacturer( manufacturer );
     get_processor_name( name );
 
-    if(!NtPowerInformation(ProcessorInformation, NULL, 0, &ppi, sizeof(ppi)))
-        cpuMhz = ppi.MaxMhz;
-    else
-        cpuMhz = 1000000;
-
+    maxclockspeed = get_processor_maxclockspeed();
     num_logical_processors = get_logical_processor_count() / count;
 
     for (i = 0; i < count; i++)
@@ -809,7 +810,7 @@ static void fill_processor( struct table *table )
         sprintfW( device_id, fmtW, i );
         rec->device_id              = heap_strdupW( device_id );
         rec->manufacturer           = heap_strdupW( manufacturer );
-        rec->maxclockspeed          = cpuMhz;
+        rec->maxclockspeed          = maxclockspeed;
         rec->name                   = heap_strdupW( name );
         rec->num_logical_processors = num_logical_processors;
         rec->processor_id           = heap_strdupW( processor_id );




More information about the wine-cvs mailing list