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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2018-01-03 15:44:47 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-01-03 15:44:47 +0300
commitbe403891652a375e5a0ac61b493342ca6d39afb7 (patch)
treeef9637103db6d66c4b311cba5b705d575562a1f8 /intern/cycles/util/util_system.cpp
parent060fdb49d64857ff1cbf9937420ed70b10b17086 (diff)
parentcbc7aa80d49e3b36c9ecc0e27ec528b34c491fc1 (diff)
Merge branch 'master' into blender2.8
Diffstat (limited to 'intern/cycles/util/util_system.cpp')
-rw-r--r--intern/cycles/util/util_system.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/intern/cycles/util/util_system.cpp b/intern/cycles/util/util_system.cpp
index a942d738b8a..9b1b9a60c30 100644
--- a/intern/cycles/util/util_system.cpp
+++ b/intern/cycles/util/util_system.cpp
@@ -292,5 +292,26 @@ bool system_cpu_support_avx2()
#endif
+size_t system_physical_ram()
+{
+#ifdef _WIN32
+ MEMORYSTATUSEX ram;
+ ram.dwLength = sizeof (ram);
+ GlobalMemoryStatusEx(&ram);
+ return ram.ullTotalPhys * 1024;
+#elif defined(__APPLE__)
+ uint64_t ram = 0;
+ size_t len = sizeof(ram);
+ if (sysctlbyname("hw.memsize", &ram, &len, NULL, 0) == 0) {
+ return ram;
+ }
+ return 0;
+#else
+ size_t ps = sysconf(_SC_PAGESIZE);
+ size_t pn = sysconf(_SC_PHYS_PAGES);
+ return ps * pn;
+#endif
+}
+
CCL_NAMESPACE_END