chiark / gitweb /
logind: make $XDG_RUNTIME_DIR a per-user tmpfs
[elogind.git] / src / shared / util.c
index 285a263cdbe5cc13a8946bc6c699e6e92fb88e43..10daff3036071a7944a826d1a080b1d4d2193caf 100644 (file)
@@ -6291,3 +6291,15 @@ const char* personality_to_string(unsigned long p) {
 
         return NULL;
 }
+
+uint64_t physical_memory(void) {
+        long mem;
+
+        /* We return this as uint64_t in case we are running as 32bit
+         * process on a 64bit kernel with huge amounts of memory */
+
+        mem = sysconf(_SC_PHYS_PAGES);
+        assert(mem > 0);
+
+        return (uint64_t) mem * (uint64_t) page_size();
+}