summaryrefslogtreecommitdiffstats
path: root/src/common/tuklib_physmem.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-15 09:41:34 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-15 09:41:34 +0000
commit25e43e389c26d56f90f2f20e3cee19c808b2a18c (patch)
treefdadca249ffd70901103b3f06a98aeab695c6193 /src/common/tuklib_physmem.c
parentAdding debian version 5.6.1+really5.4.5-1. (diff)
downloadxz-utils-25e43e389c26d56f90f2f20e3cee19c808b2a18c.tar.xz
xz-utils-25e43e389c26d56f90f2f20e3cee19c808b2a18c.zip
Merging upstream version 5.6.2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/common/tuklib_physmem.c')
-rw-r--r--src/common/tuklib_physmem.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/src/common/tuklib_physmem.c b/src/common/tuklib_physmem.c
index 69f6fd4..1009df1 100644
--- a/src/common/tuklib_physmem.c
+++ b/src/common/tuklib_physmem.c
@@ -1,3 +1,5 @@
+// SPDX-License-Identifier: 0BSD
+
///////////////////////////////////////////////////////////////////////////////
//
/// \file tuklib_physmem.c
@@ -5,9 +7,6 @@
//
// Author: Lasse Collin
//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
///////////////////////////////////////////////////////////////////////////////
#include "tuklib_physmem.h"
@@ -73,23 +72,20 @@
#endif
-// With GCC >= 8.1 with -Wextra and Clang >= 13 with -Wcast-function-type
-// will warn about the Windows-specific code.
-#if defined(__has_warning)
-# if __has_warning("-Wcast-function-type")
-# define CAN_DISABLE_WCAST_FUNCTION_TYPE 1
-# endif
-#elif TUKLIB_GNUC_REQ(8,1)
-# define CAN_DISABLE_WCAST_FUNCTION_TYPE 1
-#endif
-
-
extern uint64_t
tuklib_physmem(void)
{
uint64_t ret = 0;
#if defined(_WIN32) || defined(__CYGWIN__)
+ // This requires Windows 2000 or later.
+ MEMORYSTATUSEX meminfo;
+ meminfo.dwLength = sizeof(meminfo);
+ if (GlobalMemoryStatusEx(&meminfo))
+ ret = meminfo.ullTotalPhys;
+
+/*
+ // Old version that is compatible with even Win95:
if ((GetVersion() & 0xFF) >= 5) {
// Windows 2000 and later have GlobalMemoryStatusEx() which
// supports reporting values greater than 4 GiB. To keep the
@@ -125,6 +121,7 @@ tuklib_physmem(void)
GlobalMemoryStatus(&meminfo);
ret = meminfo.dwTotalPhys;
}
+*/
#elif defined(__OS2__)
unsigned long mem;