Skip to content

Commit

Permalink
sysinfo: Add memory size detection support for illumos and Solaris
Browse files Browse the repository at this point in the history
  • Loading branch information
mtelka authored and ximion committed Dec 7, 2024
1 parent de534e9 commit f6f2b58
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/as-system-info.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
#include <mach/mach.h>
#include <mach/host_info.h>
#include <mach/mach_host.h>
#elif defined(__sun)
#include <unistd.h>
#endif
#ifdef HAVE_SYSTEMD
#include <systemd/sd-hwdb.h>
Expand Down Expand Up @@ -511,6 +513,12 @@ as_get_physical_memory_total (void)
return 0;
}
return hbi.memory_size / MB_IN_BYTES;
#elif defined(__sun)
long physpages = sysconf(_SC_PHYS_PAGES);
long pagesize = sysconf(_SC_PAGESIZE);
if (physpages > 0 && pagesize > 0)
return (physpages * pagesize) / MB_IN_BYTES;
return 0;
#else
#error "Implementation of as_get_physical_memory_total() missing for this OS."
#endif
Expand Down

0 comments on commit f6f2b58

Please sign in to comment.