[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 05/12] util/oslib-win32: add qemu_get_host_physmem impleme
From: |
Philippe Mathieu-Daudé |
Subject: |
Re: [PATCH v2 05/12] util/oslib-win32: add qemu_get_host_physmem implementation |
Date: |
Wed, 22 Jul 2020 08:49:03 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 |
On 7/22/20 8:28 AM, Alex Bennée wrote:
> It seems GetPhysicallyInstalledSystemMemory isn't available in the
> MinGW headers so we have to declare it ourselves. Compile tested only.
>
> Cc: Stefan Weil <sw@weilnetz.de>
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> util/oslib-win32.c | 15 +++++++++++++--
> 1 file changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/util/oslib-win32.c b/util/oslib-win32.c
> index 31030463cc9..f0f94833197 100644
> --- a/util/oslib-win32.c
> +++ b/util/oslib-win32.c
> @@ -43,6 +43,8 @@
> /* this must come after including "trace.h" */
> #include <shlobj.h>
>
> +WINBASEAPI BOOL WINAPI GetPhysicallyInstalledSystemMemory (PULONGLONG);
> +
> void *qemu_oom_check(void *ptr)
> {
> if (ptr == NULL) {
> @@ -831,6 +833,15 @@ char *qemu_get_host_name(Error **errp)
>
> size_t qemu_get_host_physmem(void)
> {
> - /* currently unimplemented */
> - return 0;
> + ULONGLONG mem;
> +
> + if (GetPhysicallyInstalledSystemMemory(&mem)) {
> + if (mem > SIZE_MAX) {
> + return SIZE_MAX;
> + } else {
> + return mem;
> + }
> + } else {
> + return 0;
> + }
> }
>
- [PATCH v2 00/12] candidate fixes for 5.1-rc1 (testing, semihosting, OOM tcg, x86 fpu), Alex Bennée, 2020/07/22
- [PATCH v2 01/12] shippable: add one more qemu to registry url, Alex Bennée, 2020/07/22
- [PATCH v2 02/12] semihosting: defer connect_chardevs a little more to use serialx, Alex Bennée, 2020/07/22
- [PATCH v2 04/12] util: add qemu_get_host_physmem utility function, Alex Bennée, 2020/07/22
- [PATCH v2 03/12] semihosting: don't send the trailing '\0', Alex Bennée, 2020/07/22
- [PATCH v2 06/12] accel/tcg: better handle memory constrained systems, Alex Bennée, 2020/07/22
- [PATCH v2 05/12] util/oslib-win32: add qemu_get_host_physmem implementation, Alex Bennée, 2020/07/22
- Re: [PATCH v2 05/12] util/oslib-win32: add qemu_get_host_physmem implementation, Yonggang Luo, 2020/07/22
[PATCH v2 08/12] linux-user: don't use MAP_FIXED in pgd_find_hole_fallback, Alex Bennée, 2020/07/22