[MLton-commit] r7183

Wesley Terpstra wesley at mlton.org
Sat Jun 20 08:06:40 PDT 2009


sysconf(_SC_PHYS_PAGES) is not available in uclibc.
sysinfo is a linux-specific call available on all architectures.


----------------------------------------------------------------------

U   mlton/trunk/runtime/platform/linux.c
U   mlton/trunk/runtime/platform/linux.h

----------------------------------------------------------------------

Modified: mlton/trunk/runtime/platform/linux.c
===================================================================
--- mlton/trunk/runtime/platform/linux.c	2009-06-20 01:48:21 UTC (rev 7182)
+++ mlton/trunk/runtime/platform/linux.c	2009-06-20 15:06:39 UTC (rev 7183)
@@ -7,7 +7,6 @@
 #include "displayMem.linux.c"
 #include "mmap-protect.c"
 #include "nonwin.c"
-#include "sysconf.c"
 #include "use-mmap.c"
 
 #ifndef EIP
@@ -78,3 +77,21 @@
         return mremap (start, oldLength, newLength, MREMAP_MAYMOVE);
 }
 
+size_t GC_pageSize (void) {
+        long int pageSize;
+
+        pageSize = sysconf (_SC_PAGESIZE);
+        if (pageSize < 0)
+                diee ("GC_pageSize error: sysconf (_SC_PAGESIZE) failed");
+
+        return (size_t)pageSize;
+}
+
+/* sysconf(_SC_PHYS_PAGES) is not portable (mipsel uclibc) */
+uintmax_t GC_physMem (void) {
+        struct sysinfo si;
+        if (sysinfo(&si) < 0)
+                diee ("GC_physMem error: sysinfo failed");
+        
+        return si.totalram;
+}

Modified: mlton/trunk/runtime/platform/linux.h
===================================================================
--- mlton/trunk/runtime/platform/linux.h	2009-06-20 01:48:21 UTC (rev 7182)
+++ mlton/trunk/runtime/platform/linux.h	2009-06-20 15:06:39 UTC (rev 7183)
@@ -26,6 +26,7 @@
 #include <sys/un.h>
 #include <sys/utsname.h>
 #include <sys/wait.h>
+#include <sys/sysinfo.h>
 #include <syslog.h>
 #include <termios.h>
 #include <utime.h>




More information about the MLton-commit mailing list