Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/kornelski/7z.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'CPP/Windows/System.cpp')
-rw-r--r--CPP/Windows/System.cpp72
1 files changed, 55 insertions, 17 deletions
diff --git a/CPP/Windows/System.cpp b/CPP/Windows/System.cpp
index 67551b6d..59cb7c0b 100644
--- a/CPP/Windows/System.cpp
+++ b/CPP/Windows/System.cpp
@@ -11,6 +11,8 @@
namespace NWindows {
namespace NSystem {
+#ifdef _WIN32
+
UInt32 GetNumberOfProcessors()
{
SYSTEM_INFO systemInfo;
@@ -18,6 +20,18 @@ UInt32 GetNumberOfProcessors()
return (UInt32)systemInfo.dwNumberOfProcessors;
}
+#else
+
+UInt32 GetNumberOfProcessors()
+{
+ return 1;
+}
+
+#endif
+
+
+#ifdef _WIN32
+
#ifndef UNDER_CE
#if !defined(_WIN64) && defined(__GNUC__)
@@ -45,29 +59,53 @@ typedef BOOL (WINAPI *GlobalMemoryStatusExP)(MY_LPMEMORYSTATUSEX lpBuffer);
#endif
-UInt64 GetRamSize()
+#endif
+
+
+bool GetRamSize(UInt64 &size)
{
+ size = (UInt64)(sizeof(size_t)) << 29;
+
+ #ifdef _WIN32
+
#ifndef UNDER_CE
- MY_MEMORYSTATUSEX stat;
- stat.dwLength = sizeof(stat);
+ MY_MEMORYSTATUSEX stat;
+ stat.dwLength = sizeof(stat);
#endif
+
#ifdef _WIN64
- if (!::GlobalMemoryStatusEx(&stat))
- return 0;
- return MyMin(stat.ullTotalVirtual, stat.ullTotalPhys);
+
+ if (!::GlobalMemoryStatusEx(&stat))
+ return false;
+ size = MyMin(stat.ullTotalVirtual, stat.ullTotalPhys);
+ return true;
+
#else
- #ifndef UNDER_CE
- GlobalMemoryStatusExP globalMemoryStatusEx = (GlobalMemoryStatusExP)
- ::GetProcAddress(::GetModuleHandle(TEXT("kernel32.dll")), "GlobalMemoryStatusEx");
- if (globalMemoryStatusEx != 0 && globalMemoryStatusEx(&stat))
- return MyMin(stat.ullTotalVirtual, stat.ullTotalPhys);
+
+ #ifndef UNDER_CE
+ GlobalMemoryStatusExP globalMemoryStatusEx = (GlobalMemoryStatusExP)
+ ::GetProcAddress(::GetModuleHandle(TEXT("kernel32.dll")), "GlobalMemoryStatusEx");
+ if (globalMemoryStatusEx && globalMemoryStatusEx(&stat))
+ {
+ size = MyMin(stat.ullTotalVirtual, stat.ullTotalPhys);
+ return true;
+ }
+ #endif
+
+ {
+ MEMORYSTATUS stat2;
+ stat2.dwLength = sizeof(stat2);
+ ::GlobalMemoryStatus(&stat2);
+ size = MyMin(stat2.dwTotalVirtual, stat2.dwTotalPhys);
+ return true;
+ }
+
#endif
- {
- MEMORYSTATUS stat;
- stat.dwLength = sizeof(stat);
- ::GlobalMemoryStatus(&stat);
- return MyMin(stat.dwTotalVirtual, stat.dwTotalPhys);
- }
+
+ #else
+
+ return false;
+
#endif
}