diff --git a/src/low_level_utils.cpp b/src/low_level_utils.cpp
index fe7a3f425acbeb849e43c8408e9e4c157439c4b3..bb26e3b3906bc0bb19402a242ee754e22ece2cd3 100644
--- a/src/low_level_utils.cpp
+++ b/src/low_level_utils.cpp
@@ -9,6 +9,9 @@
 #include <iostream>
 #include <sys/stat.h>
 #include <sys/sysctl.h>
+#if !defined(_SC_PHYS_PAGES) and !__APPLE__
+    #include <sys/sysinfo.h>
+#endif
 #include "low_level_utils.h"
 
 using namespace std;
@@ -51,8 +54,7 @@ unsigned long getNodePhysMemory() {
 	mem=0;
     }
     mem /=  1 * 1024 * 1024 * 1024;
-#else
-#include <sys/sysinfo.h>
+#elif !defined(_SC_PHYS_PAGES) and !__APPLE__
     struct sysinfo si;
     int ret=sysinfo(&si);
     if (ret==-1) {