From patchwork Wed Jul 22 06:28:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 246972 Delivered-To: patch@linaro.org Received: by 2002:a92:d244:0:0:0:0:0 with SMTP id v4csp269686ilg; Tue, 21 Jul 2020 23:34:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy0nvDxOAr+9cFpVv1smVNyjC06qb46AdDTy4MxY04sEJKKo+QEfw1TY78kT3Zh3hv/jtfn X-Received: by 2002:a25:ec0e:: with SMTP id j14mr48171264ybh.173.1595399641675; Tue, 21 Jul 2020 23:34:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595399641; cv=none; d=google.com; s=arc-20160816; b=s8ryltDOoXQpi/YnQ35aQk6xYTpyBjW/YMhuqxhcrL8+nz5oVH0B/OT3jvHkNvv/2Z ZSFZM4fJgzeA1HgRFJOw7GNt49bbVLBZLY/+cNYAul6bfBzYdFXnQCyQMY573Baa/wHh r5mm1S+2VKXJ8pUY44XmsJlCdTg5X7HyC2nEyxA6lmwYNXICHxVpYa6y43BydU1DJi96 XVcSfPRNDQBBtgZxKsDQSopknzNB8qrz+6z0wk99GKcB9gGcKqUwEmQbmQdjSDk5OWXf 0hwrcXKmPR3ZsDvoqKaWfmLrdG9UiiBP/znRmHZwb9hYodw9svre9UxNqaejwZfsbIFo kGHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=UjtgMi3yK33ZjhmVkRGlgMB3WMVIed90Ngc7ulb8I7c=; b=sOrAQnsKr9FeeFp9Dug+9xN/15H5qS69SEYYQyf1HKcn3ZBZxqN/uD/LvP1FOVW9/X fpr3Gr/u/xTIry9I+eW4qEE4uJ7hkC/5bArHI2kosHiZs/k2XOCyrXFCT8WFJYY6ftTy AyDvt77zUs1WrIBRT5Jha4vLUGEt1fLtRtAgB3ZcnJASP6HqqEW5nAbE09E2rRCNcuEU ANNmODLbdpIlLzU5A/oUTO/ZckR+MErzB3dIQnkNxLdYfr7xoB1JXqiiLghhgGqFB7Ve GPPhCdd5wWnxTy+xnz6cO5zrYbNK+MS8C3GSXNmsZ/kiDzgjby2T7IgA8Uxujmu6AFKY lLbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=F9+l6cOY; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id g133si9490184ybb.2.2020.07.21.23.34.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 Jul 2020 23:34:01 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=F9+l6cOY; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39326 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jy8KH-0005Ih-3W for patch@linaro.org; Wed, 22 Jul 2020 02:34:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41326) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jy8Fg-0007AU-DH for qemu-devel@nongnu.org; Wed, 22 Jul 2020 02:29:16 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:37898) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jy8Fe-0006vC-Tc for qemu-devel@nongnu.org; Wed, 22 Jul 2020 02:29:16 -0400 Received: by mail-wm1-x342.google.com with SMTP id f18so837617wml.3 for ; Tue, 21 Jul 2020 23:29:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UjtgMi3yK33ZjhmVkRGlgMB3WMVIed90Ngc7ulb8I7c=; b=F9+l6cOYOB3MiOiDh5JXDMQ70OsszixR6C/OvcWj6quO1dKI6derFoOEOhHyEKfPFz Eit2iB91yDBreCmGOz8kSlIVl09cvJ5ho7vwrhW3lGlZ27BkLORTFCpqFmGiksK/qqsk FfxuREQa8EUAktPQ4+u5RlfQn3fQbEpbx0dLwp1pDnj0Dt/7P+HpoX7HKSkshl//6k1w 6J5Xo+CKkeSSwb9lb870UfGReYkdJ21h6FsJDhbOjJEvVs+5ucHD9Mxeps8JdmgiKA42 465ZwxAg7L2TmHw/240rdbK7QuG3W50rht8s5UDbaRlJZuSlM2rumzVILJKDTKJstxdP f54Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UjtgMi3yK33ZjhmVkRGlgMB3WMVIed90Ngc7ulb8I7c=; b=Mk0F+vJD+zY8LekJxvw05wdyEOu9X1T7flxUtDblMq5KELJ3iV/NGinfbSVDgs8LTC B0wW+Stl7SJks8DXMKvsv35n9+F8bYqPpV53397hHCt7cTHfzCV6wUVeyl0PA7sk3xt6 wOTzJpHmATkLXmTo4Bw8t93c4/attVtHx0jbpC3af8sQbbh1vctknUqH9APqF3Xmstqt ouyZ7+wnE87s8khNzGilSz0RA+QZ4RPi9nr92BSJuF40kWCiadImi6vrQZW7QuRfsqCf lUCLmdMkhyFct00I4j5MG36hlPRmUmSu2924i1tdGyLyL03eXY39qHbdFDl5FhqRiaxy eElQ== X-Gm-Message-State: AOAM530tPP/51DuL5N6lvYXf2hHbYNK9W2XO8jtAHfomQpEAeAJWeK62 3ox89w7E8VyO++TmfoIbmlnXlw== X-Received: by 2002:a1c:dd86:: with SMTP id u128mr7085401wmg.123.1595399353628; Tue, 21 Jul 2020 23:29:13 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id j8sm24537574wrd.85.2020.07.21.23.29.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jul 2020 23:29:09 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 7172A1FF91; Wed, 22 Jul 2020 07:29:03 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v2 05/12] util/oslib-win32: add qemu_get_host_physmem implementation Date: Wed, 22 Jul 2020 07:28:55 +0100 Message-Id: <20200722062902.24509-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200722062902.24509-1-alex.bennee@linaro.org> References: <20200722062902.24509-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::342; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x342.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: fam@euphon.net, berrange@redhat.com, =?utf-8?q?Alex_Benn=C3=A9e?= , richard.henderson@linaro.org, f4bug@amsat.org, cota@braap.org, Stefan Weil , aurelien@aurel32.net Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" It seems GetPhysicallyInstalledSystemMemory isn't available in the MinGW headers so we have to declare it ourselves. Compile tested only. Cc: Stefan Weil Signed-off-by: Alex Bennée --- util/oslib-win32.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) -- 2.20.1 Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
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 +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; + } }