[wbemprox] Patches for adding currentclockspeed in record_processor

Hans Leidekker hans at codeweavers.com
Mon Jul 1 03:02:34 CDT 2013


On Mon, 2013-07-01 at 08:56 +0900, Rosen Diankov wrote:

> diff -ru wine-1.6-rc3-old/dlls/wbemprox/builtin.c wine-1.6-rc3/dlls/wbemprox/builtin.c
> --- wine-1.6-rc3-old/dlls/wbemprox/builtin.c    2013-06-22 03:24:01.000000000 +0900
> +++ wine-1.6-rc3/dlls/wbemprox/builtin.c        2013-06-27 23:04:20.170154454 +0900

Please use git to generate patches.

> @@ -168,6 +168,8 @@
>      {'M','a','n','u','f','a','c','t','u','r','e','r',0};
>  static const WCHAR prop_maxclockspeedW[] =
>      {'M','a','x','C','l','o','c','k','S','p','e','e','d',0};
> +static const WCHAR prop_currentclockspeedW[] =
> +    {'C','u','r','r','e','n','t','C','l','o','c','k','S','p','e','e','d',0};

Please keep properties sorted here and below.

>  static const WCHAR prop_memberW[] =
>      {'M','e','m','b','e','r',0};
>  static const WCHAR prop_methodW[] =
> @@ -381,6 +383,7 @@
>      { prop_familyW,               CIM_UINT16, VT_I4 },
>      { prop_manufacturerW,         CIM_STRING|COL_FLAG_DYNAMIC },
>      { prop_maxclockspeedW,        CIM_UINT32, VT_I4 },
> +    { prop_currentclockspeedW,    CIM_UINT32, VT_I4 },
>      { prop_nameW,                 CIM_STRING|COL_FLAG_DYNAMIC },
>      { prop_numcoresW,             CIM_UINT32, VT_I4 },
>      { prop_numlogicalprocessorsW, CIM_UINT32, VT_I4 },
> @@ -633,6 +636,7 @@
>      UINT16       family;
>      const WCHAR *manufacturer;
>      UINT32       maxclockspeed;
> +    UINT32       currentclockspeed;
>      const WCHAR *name;
>      UINT32       num_cores;
>      UINT32       num_logical_processors;
> @@ -1690,7 +1694,33 @@
>          regs_to_str( regs, 16, name + 32 );
>      }
>  }
> -static UINT get_processor_maxclockspeed( void )
> +static void get_processor_clockspeeds( UINT* maxclockspeed, UINT* currentclockspeed )
> +{
> +    PROCESSOR_POWER_INFORMATION *info;
> +    UINT size = get_processor_count() * sizeof(PROCESSOR_POWER_INFORMATION);
> +    NTSTATUS status;
> +
> +    if ((info = heap_alloc( size )))
> +    {
> +        status = NtPowerInformation( ProcessorInformation, NULL, 0, info, size );
> +        if (!status)
> +        {
> +            *maxclockspeed = info[0].MaxMhz;
> +            *currentclockspeed = info[0].CurrentMhz;
> +        }
> +        heap_free( info );
> +    }
> +    if( !!maxclockspeed )
> +    {
> +        *maxclockspeed = 1000;
> +    }
> +    if( !!currentclockspeed )
> +    {
> +        *currentclockspeed = 1000;
> +    }
> +}

You probably didn't mean to query the clock speeds and then overwrite them with static values.
NULL checks are not needed in helpers like this.

> +/*static UINT get_processor_maxclockspeed( void )
>  {
>      PROCESSOR_POWER_INFORMATION *info;
>      UINT ret = 1000, size = get_processor_count() * sizeof(PROCESSOR_POWER_INFORMATION);
> @@ -1703,7 +1733,8 @@
>          heap_free( info );
>      }
>      return ret;
> -}
> +}*/

Don't comment out code. Remove it.

>  static const WCHAR *get_osarchitecture(void)
>  {
>      SYSTEM_INFO info;
> @@ -1717,7 +1748,7 @@
>      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, maxclockspeed, num_cores, num_logical_processors, count = get_processor_count();
> +    UINT i, offset = 0, maxclockspeed = 0, currentclockspeed = 0, num_cores, num_logical_processors, count = get_processor_count();
>      enum fill_status status = FILL_STATUS_UNFILTERED;
>  
>      if (!resize_table( table, count, sizeof(*rec) )) return FILL_STATUS_FAILED;
> @@ -1726,7 +1757,7 @@
>      get_processor_manufacturer( manufacturer );
>      get_processor_name( name );
>  
> -    maxclockspeed = get_processor_maxclockspeed();
> +    get_processor_clockspeeds(&maxclockspeed, &currentclockspeed);
>      num_logical_processors = get_logical_processor_count( &num_cores ) / count;
>      num_cores /= count;

You're not using currentclockspeed.





More information about the wine-devel mailing list