qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2 1/3] compiler: define QEMU_CACHELINE_SIZE


From: Geert Martin Ijewski
Subject: Re: [Qemu-devel] [PATCH v2 1/3] compiler: define QEMU_CACHELINE_SIZE
Date: Wed, 7 Jun 2017 00:01:49 +0200
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1

Am 06.06.2017 um 23:38 schrieb Emilio G. Cota:
> On Tue, Jun 06, 2017 at 22:28:23 +0200, Geert Martin Ijewski wrote:
>> On a fully patched Windows 10 with an i5-4690 this code works for me (TM):
>
> Thanks!
> Can you please test this?
>
>            Emilio
> ---
> #include "qemu/osdep.h"
> #include <windows.h>

unnecassary as it's already included by qemu/osdep.h -> sysemu/os-win32.h
>
> static unsigned int linesize_win(PROCESSOR_CACHE_TYPE type)
> {
>      PSYSTEM_LOGICAL_PROCESSOR_INFORMATION buf;
>      DWORD size = 0;
>      unsigned int ret = 0;
>      BOOL success;
>      size_t n;
>      size_t i;
>
>      success = GetLogicalProcessorInformation(0, &size);
>      if (success || GetLastError() != ERROR_INSUFFICIENT_BUF) {
>          return 0;
>      }
>      buf = (PSYSTEM_LOGICAL_PROCESSOR_INFORMATION)g_malloc0(size);
>      if (!GetLogicalProcessorInformation(buf, &size)) {
>          goto out;
>      }
>
>      n = size / sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION);
>      for (i = 0; i < n; i++) {
>          if (buf[i].Relationship == RelationCache &&
>              buf[i].Cache.Level == 1 &&
>              (buf[i].Cache.Type == CacheUnified ||
>               buf[i].Cache.Type == type)) {
>              ret = buf[i].Cache.LineSize;
>              break;
>          }
>      }
>   out:
>      g_free(buf);
>      return ret;
> }
>
> linesize_win(CacheInstruction);
> linesize_win(CacheData);
>
>

Yes, that works.
Tested-by: Geert Martin Ijewski <address@hidden>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]