Sisyphus repositório
Última atualização: 1 outubro 2023 | SRPMs: 18631 | Visitas: 37385551
en ru br
ALT Linux repositórios
S:0.9.11-alt2.1

Group :: Sistema/Kernel e hardware
RPM: fuse-cryfs

 Main   Changelog   Spec   Patches   Sources   Download   Gear   Bugs e FR  Repocop 

Patch: fuse-cryfs-glibc-compat.patch
Download


diff --git a/fuse-cryfs/src/cpp-utils/system/get_total_memory.cpp b/fuse-cryfs/src/cpp-utils/system/get_total_memory.cpp
index 83abe6c..85f197c 100644
--- a/fuse-cryfs/src/cpp-utils/system/get_total_memory.cpp
+++ b/fuse-cryfs/src/cpp-utils/system/get_total_memory.cpp
@@ -1,27 +1,58 @@
 #include "get_total_memory.h"
-#include <sys/types.h>
-#include <sys/sysctl.h>
-#include <unistd.h>
 #include <stdexcept>
+#include <string>
 
-namespace cpputils{
-    namespace system {
-        uint64_t get_total_memory() {
-            uint64_t mem;
 #if defined(__APPLE__)
-            size_t size = sizeof(mem);
-  int result = sysctlbyname("hw.memsize", &mem, &size, nullptr, 0);
-  if (0 != result) {
-    throw std::runtime_error("sysctlbyname syscall failed");
-  }
+
+#include <sys/types.h>
+#include <sys/sysctl.h>
+
+namespace cpputils {
+	namespace system {
+		uint64_t get_total_memory() {
+			uint64_t mem;
+			size_t size = sizeof(mem);
+			int result = sysctlbyname("hw.memsize", &mem, &size, nullptr, 0);
+			if (0 != result) {
+				throw std::runtime_error("sysctlbyname syscall failed");
+			}
+			return mem;
+		}
+	}
+}
+
 #elif defined(__linux__) || defined(__FreeBSD__)
-            long numRAMPages = sysconf(_SC_PHYS_PAGES);
-            long pageSize = sysconf(_SC_PAGESIZE);
-            mem = numRAMPages * pageSize;
+
+#include <unistd.h>
+
+namespace cpputils {
+	namespace system {
+		uint64_t get_total_memory() {
+			long numRAMPages = sysconf(_SC_PHYS_PAGES);
+			long pageSize = sysconf(_SC_PAGESIZE);
+			return numRAMPages * pageSize;
+		}
+	}
+}
+
+#elif defined(_MSC_VER)
+
+#include <Windows.h>
+
+namespace cpputils {
+	namespace system {
+		uint64_t get_total_memory() {
+			MEMORYSTATUSEX status;
+			status.dwLength = sizeof(status);
+			if (!::GlobalMemoryStatusEx(&status)) {
+				throw std::runtime_error("Couldn't get system memory information. Error code: " + std::to_string(GetLastError()));
+			}
+			return status.ullTotalPhys;
+		}
+	}
+}
+
 #else
-#error Not supported on windows yet, TODO http://stackoverflow.com/a/2513561/829568
+#error Unsupported platform
 #endif
-            return mem;
-        }
-    }
-}
+
 
projeto & código: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
mantenedor atual: Michael Shigorin
mantenedor da tradução: Fernando Martini aka fmartini © 2009