[MLton-commit] r4232

Matthew Fluet MLton@mlton.org
Tue, 15 Nov 2005 16:33:17 -0800


Fixing lots of missing prototypes
----------------------------------------------------------------------

U   mlton/branches/on-20050822-x86_64-branch/basis-library/misc/primitive.sml
U   mlton/branches/on-20050822-x86_64-branch/basis-library/mlton/rusage.sml
U   mlton/branches/on-20050822-x86_64-branch/runtime/Makefile
U   mlton/branches/on-20050822-x86_64-branch/runtime/Posix/Error.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/Dirstream.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/getcwd.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/Posix/ProcEnv/ProcEnv.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/Posix/ProcEnv/getenv.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/Posix/ProcEnv/getlogin.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/Posix/ProcEnv/setgroups.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/Posix/ProcEnv/ttyname.c
D   mlton/branches/on-20050822-x86_64-branch/runtime/basis/Array/
U   mlton/branches/on-20050822-x86_64-branch/runtime/basis/IntInf.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/basis/MLton/rusage.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/basis/MLton/spawne.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/basis/MLton/spawnp.c
A   mlton/branches/on-20050822-x86_64-branch/runtime/basis/Net/Socket/GenericSock.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/basis/Net/Socket/Socket.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/Math.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/gdtoa.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/modf.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/strto.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/basis/Stdio.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/invariant.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/platform/linux.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/platform/mmap-protect.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/platform.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/platform.h

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

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library/misc/primitive.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library/misc/primitive.sml	2005-11-15 23:55:59 UTC (rev 4231)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/misc/primitive.sml	2005-11-16 00:33:09 UTC (rev 4232)
@@ -219,7 +219,6 @@
       structure Stdio =
          struct
             val print = _import "Stdio_print": string -> unit;
-            (* val sprintf = _import "Stdio_sprintf": char array * nullString * real -> int; *)
          end
 
       structure Array =
@@ -1088,7 +1087,7 @@
             
             structure Rusage =
                struct
-                 val ru = _import "MLton_Rusage_ru": unit -> unit;
+                 val ru = _import "MLton_Rusage_ru": GCState.t -> unit;
                     
                  val self_utime_sec = _import "MLton_Rusage_self_utime_sec": unit -> int;
                  val self_utime_usec = _import "MLton_Rusage_self_utime_usec": unit -> int;

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library/mlton/rusage.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library/mlton/rusage.sml	2005-11-15 23:55:59 UTC (rev 4231)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/mlton/rusage.sml	2005-11-16 00:33:09 UTC (rev 4232)
@@ -9,6 +9,7 @@
 structure MLtonRusage: MLTON_RUSAGE =
    struct
       structure Prim = Primitive.MLton.Rusage
+      val gcState = Primitive.GCState.gcState
 
       type t = {utime: Time.time, stime: Time.time}
 
@@ -36,7 +37,7 @@
          in
             fn () =>
             let
-               val () = Prim.ru ()
+               val () = Prim.ru gcState
                open Prim
             in
                {children = collect (children_utime_sec, children_utime_usec,

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/Makefile
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/Makefile	2005-11-15 23:55:59 UTC (rev 4231)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/Makefile	2005-11-16 00:33:09 UTC (rev 4232)
@@ -181,16 +181,16 @@
 # are class.c and gdtoa.c.  But there may be others.  So, we compile
 # with -fno-strict-aliasing to prevent gcc from taking advantage of
 # this aspect of the C spec.
-basis/Real/%-gdb.o: basis/Real/%.c gdtoa/arith.h
-	$(CC) $(DEBUGCFLAGS) -c -o $@ $<
-basis/Real/%.o: basis/Real/%.c gdtoa/arith.h
-	$(CC) $(OPTCFLAGS) -O1 -fno-strict-aliasing -c -o $@ $<
+basis/Real/%-gdb.o: basis/Real/%.c gdtoa/arith.h $(HFILES)
+	$(CC) $(DEBUGCFLAGS) $(DEBUGWARNFLAGS) -c -o $@ $<
+basis/Real/%.o: basis/Real/%.c gdtoa/arith.h  $(HFILES)
+	$(CC) $(OPTCFLAGS) $(OPTWARNFLAGS) -O1 -fno-strict-aliasing -c -o $@ $<
 
 %-gdb.o: %.c $(HFILES)
-	$(CC) $(DEBUGCFLAGS) -c -o $@ $<
+	$(CC) $(DEBUGCFLAGS) $(DEBUGWARNFLAGS) -c -o $@ $<
 
 %.o: %.c $(HFILES)
-	$(CC) $(OPTCFLAGS) -c -o $@ $<
+	$(CC) $(OPTCFLAGS) $(OPTWARNFLAGS) -c -o $@ $<
 
 %-gdb.o: %.S
 	$(CC) $(DEBUGCFLAGS) -c -o $@ $<

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/Posix/Error.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/Posix/Error.c	2005-11-15 23:55:59 UTC (rev 4231)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/Posix/Error.c	2005-11-16 00:33:09 UTC (rev 4232)
@@ -9,5 +9,6 @@
 }
 
 Cstring Posix_Error_strerror (Int n) {
-        return (Cstring)(strerror (n));
+        char *res = strerror (n);
+        return (Cstring)res;
 }

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/Dirstream.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/Dirstream.c	2005-11-15 23:55:59 UTC (rev 4231)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/Dirstream.c	2005-11-16 00:33:09 UTC (rev 4232)
@@ -13,14 +13,9 @@
         return res;
 }
 
-Cpointer Posix_FileSys_Dirstream_opendir (Cpointer p) {
-        Cpointer res;
-
-        res = (Cpointer)(opendir ((char *) p));
-        if (DEBUG_DIRSTREAM)
-                fprintf (stderr, "0x%08x = opendir (%s)\n", 
-                                (uint)res, (char *)p);
-        return res;
+Cpointer Posix_FileSys_Dirstream_opendir (Pointer p) {
+        DIR *res = opendir ((char *) p);
+        return (Cpointer)res;
 }
 
 Cstring Posix_FileSys_Dirstream_readdir (Cpointer d) {

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/getcwd.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/getcwd.c	2005-11-15 23:55:59 UTC (rev 4231)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/getcwd.c	2005-11-16 00:33:09 UTC (rev 4232)
@@ -1,5 +1,6 @@
 #include "platform.h"
 
 Cstring Posix_FileSys_getcwd (Pointer buf, Size n) {
-        return (Cstring)(getcwd ((char*)buf, n));
+        char *res = getcwd ((char*)buf, n);
+        return (Cstring)res;
 }

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/Posix/ProcEnv/ProcEnv.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/Posix/ProcEnv/ProcEnv.c	2005-11-15 23:55:59 UTC (rev 4231)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/Posix/ProcEnv/ProcEnv.c	2005-11-16 00:33:09 UTC (rev 4232)
@@ -1,7 +1,8 @@
 #include "platform.h"
 
 Cstring Posix_ProcEnv_ctermid () {
-        return (Cstring)(ctermid (NULL));
+        char *res = ctermid (NULL);
+        return (Cstring)res;
 }
 
 Gid Posix_ProcEnv_getegid () {

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/Posix/ProcEnv/getenv.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/Posix/ProcEnv/getenv.c	2005-11-15 23:55:59 UTC (rev 4231)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/Posix/ProcEnv/getenv.c	2005-11-16 00:33:09 UTC (rev 4232)
@@ -1,5 +1,6 @@
 #include "platform.h"
 
 Cstring Posix_ProcEnv_getenv(Pointer s) {
-        return (Cstring)getenv((char *)s);
+        char *res = getenv((char *)s);
+        return (Cstring)res;
 }

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/Posix/ProcEnv/getlogin.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/Posix/ProcEnv/getlogin.c	2005-11-15 23:55:59 UTC (rev 4231)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/Posix/ProcEnv/getlogin.c	2005-11-16 00:33:09 UTC (rev 4232)
@@ -1,5 +1,6 @@
 #include "platform.h"
 
 Cstring Posix_ProcEnv_getlogin () {
-        return (Cstring)(getlogin ());
+        char *res = getlogin ();
+        return (Cstring)(res);
 }

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/Posix/ProcEnv/setgroups.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/Posix/ProcEnv/setgroups.c	2005-11-15 23:55:59 UTC (rev 4231)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/Posix/ProcEnv/setgroups.c	2005-11-16 00:33:09 UTC (rev 4232)
@@ -4,7 +4,7 @@
         int i;
         gid_t *list;
         int res;
-        int size;
+        uintmax_t size;
 
         size = GC_getArrayLength (groups);
         list = (gid_t*)(calloc_safe (size, sizeof(*list)));

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/Posix/ProcEnv/ttyname.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/Posix/ProcEnv/ttyname.c	2005-11-15 23:55:59 UTC (rev 4231)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/Posix/ProcEnv/ttyname.c	2005-11-16 00:33:09 UTC (rev 4232)
@@ -1,5 +1,6 @@
 #include "platform.h"
 
 Cstring Posix_ProcEnv_ttyname (Fd f) {
-        return (Cstring)(ttyname (f));
+        char *res = ttyname (f);
+        return (Cstring)res;
 }

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/basis/IntInf.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/basis/IntInf.c	2005-11-15 23:55:59 UTC (rev 4231)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/IntInf.c	2005-11-16 00:33:09 UTC (rev 4232)
@@ -79,15 +79,16 @@
 /*
  * Initialize an __mpz_struct to use the space provided by an ML array.
  */
-static inline void initRes (__mpz_struct *mpzp, uint bytes) {
+static inline void initRes (__mpz_struct *mpzp, size_t bytes) {
         GC_intInf bp;
 
-        assert (bytes <= gcState.limitPlusSlop - gcState.frontier);
+        assert (bytes <= (size_t)(gcState.limitPlusSlop - gcState.frontier));
         bp = (GC_intInf)gcState.frontier;
-        /* We have as much space for the limbs as there is to the end of the 
-         * heap.  Divide by 4 to get number of words. 
+        /* We have as much space for the limbs as there is to the end
+         * of the heap.  Divide by (sizeof(mp_limb_t)) to get number
+         * of limbs.
          */
-        mpzp->_mp_alloc = (gcState.limitPlusSlop - (pointer)bp->limbs) / 4;
+        mpzp->_mp_alloc = (gcState.limitPlusSlop - (pointer)bp->limbs) / (sizeof(mp_limb_t));
         mpzp->_mp_size = 0; /* is this necessary? */
         mpzp->_mp_d = (mp_limb_t*)(bp->limbs);
 }
@@ -108,9 +109,9 @@
         return (res);
 }
 
-static inline void setFrontier (pointer p, uint bytes) {
+static inline void setFrontier (pointer p, size_t bytes) {
         p = GC_alignFrontier (&gcState, p);
-        assert (p - gcState.frontier <= bytes);
+        assert ((size_t)(p - gcState.frontier) <= bytes);
         GC_profileAllocInc (&gcState, p - gcState.frontier);
         gcState.frontier = p;
         assert (gcState.frontier <= gcState.limitPlusSlop);
@@ -124,7 +125,7 @@
  * If the answer doesn't need all of the space allocated, we adjust
  * the array size and roll the frontier slightly back.
  */
-static pointer answer (__mpz_struct *ans, uint bytes) {
+static pointer answer (__mpz_struct *ans, size_t bytes) {
         GC_intInf               bp;
         int                     size;
 
@@ -166,7 +167,7 @@
         return (pointer)&bp->isneg;
 }
 
-static inline pointer binary (pointer lhs, pointer rhs, uint bytes,
+static inline pointer binary (pointer lhs, pointer rhs, size_t bytes,
                                 void(*binop)(__mpz_struct *resmpz, 
                                         __gmp_const __mpz_struct *lhsspace,
                                         __gmp_const __mpz_struct *rhsspace)) {
@@ -183,57 +184,57 @@
         return answer (&resmpz, bytes);
 }
 
-pointer IntInf_add (pointer lhs, pointer rhs, uint bytes) {
+pointer IntInf_add (pointer lhs, pointer rhs, size_t bytes) {
         if (DEBUG_INT_INF)
-                fprintf (stderr, "IntInf_add ("FMTPTR", "FMTPTR", %u)\n",
+                fprintf (stderr, "IntInf_add ("FMTPTR", "FMTPTR", %zu)\n",
                                 (uintptr_t)lhs, (uintptr_t)rhs, bytes);
         return binary (lhs, rhs, bytes, &mpz_add);
 }
 
-pointer IntInf_gcd (pointer lhs, pointer rhs, uint bytes) {
+pointer IntInf_gcd (pointer lhs, pointer rhs, size_t bytes) {
         if (DEBUG_INT_INF)
-                fprintf (stderr, "IntInf_gcd ("FMTPTR", "FMTPTR", %u)\n",
+                fprintf (stderr, "IntInf_gcd ("FMTPTR", "FMTPTR", %zu)\n",
                                 (uintptr_t)lhs, (uintptr_t)rhs, bytes);
         return binary (lhs, rhs, bytes, &mpz_gcd);
 }
 
-pointer IntInf_mul (pointer lhs, pointer rhs, uint bytes) {
+pointer IntInf_mul (pointer lhs, pointer rhs, size_t bytes) {
         if (DEBUG_INT_INF)
-                fprintf (stderr, "IntInf_mul ("FMTPTR", "FMTPTR", %u)\n",
+                fprintf (stderr, "IntInf_mul ("FMTPTR", "FMTPTR", %zu)\n",
                                 (uintptr_t)lhs, (uintptr_t)rhs, bytes);
         return binary (lhs, rhs, bytes, &mpz_mul);
 }
 
-pointer IntInf_sub (pointer lhs, pointer rhs, uint bytes) {
+pointer IntInf_sub (pointer lhs, pointer rhs, size_t bytes) {
         if (DEBUG_INT_INF)
-                fprintf (stderr, "IntInf_sub ("FMTPTR", "FMTPTR", %u)\n",
+                fprintf (stderr, "IntInf_sub ("FMTPTR", "FMTPTR", %zu)\n",
                                 (uintptr_t)lhs, (uintptr_t)rhs, bytes);
         return binary (lhs, rhs, bytes, &mpz_sub);
 }
 
-pointer IntInf_andb(pointer lhs, pointer rhs, uint bytes) {
+pointer IntInf_andb(pointer lhs, pointer rhs, size_t bytes) {
         if (DEBUG_INT_INF)
-                fprintf (stderr, "IntInf_andb ("FMTPTR", "FMTPTR", %u)\n",
+                fprintf (stderr, "IntInf_andb ("FMTPTR", "FMTPTR", %zu)\n",
                                 (uintptr_t)lhs, (uintptr_t)rhs, bytes);
         return binary(lhs, rhs, bytes, &mpz_and);
 }
 
-pointer IntInf_orb(pointer lhs, pointer rhs, uint bytes) {
+pointer IntInf_orb(pointer lhs, pointer rhs, size_t bytes) {
         if (DEBUG_INT_INF)
-                fprintf (stderr, "IntInf_orb ("FMTPTR", "FMTPTR", %u)\n",
+                fprintf (stderr, "IntInf_orb ("FMTPTR", "FMTPTR", %zu)\n",
                                 (uintptr_t)lhs, (uintptr_t)rhs, bytes);
         return binary(lhs, rhs, bytes, &mpz_ior);
 }
 
-pointer IntInf_xorb(pointer lhs, pointer rhs, uint bytes) {
+pointer IntInf_xorb(pointer lhs, pointer rhs, size_t bytes) {
         if (DEBUG_INT_INF)
-                fprintf (stderr, "IntInf_xorb ("FMTPTR", "FMTPTR", %u)\n",
+                fprintf (stderr, "IntInf_xorb ("FMTPTR", "FMTPTR", %zu)\n",
                                 (uintptr_t)lhs, (uintptr_t)rhs, bytes);
         return binary(lhs, rhs, bytes, &mpz_xor);
 }
 
 static pointer
-unary(pointer arg, uint bytes,
+unary(pointer arg, size_t bytes,
       void(*unop)(__mpz_struct *resmpz, 
                   __gmp_const __mpz_struct *argspace))
 {
@@ -247,22 +248,22 @@
         return answer (&resmpz, bytes);
 }
 
-pointer IntInf_neg(pointer arg, uint bytes) {
+pointer IntInf_neg(pointer arg, size_t bytes) {
         if (DEBUG_INT_INF)
-                fprintf (stderr, "IntInf_neg ("FMTPTR", %u)\n",
+                fprintf (stderr, "IntInf_neg ("FMTPTR", %zu)\n",
                                 (uintptr_t)arg, bytes);
         return unary(arg, bytes, &mpz_neg);
 }
 
-pointer IntInf_notb(pointer arg, uint bytes) {
+pointer IntInf_notb(pointer arg, size_t bytes) {
         if (DEBUG_INT_INF)
-                fprintf (stderr, "IntInf_notb ("FMTPTR", %u)\n",
+                fprintf (stderr, "IntInf_notb ("FMTPTR", %zu)\n",
                                 (uintptr_t)arg, bytes);
         return unary(arg, bytes, &mpz_com);
 }
 
 static pointer
-shary(pointer arg, uint shift, uint bytes,
+shary(pointer arg, uint shift, size_t bytes,
       void(*shop)(__mpz_struct *resmpz, 
                   __gmp_const __mpz_struct *argspace,
                   unsigned long shift))
@@ -277,16 +278,16 @@
         return answer (&resmpz, bytes);
 }
 
-pointer IntInf_arshift(pointer arg, uint shift, uint bytes) {
+pointer IntInf_arshift(pointer arg, uint shift, size_t bytes) {
         if (DEBUG_INT_INF)
-                fprintf (stderr, "IntInf_arshift ("FMTPTR", %u, %u)\n",
+                fprintf (stderr, "IntInf_arshift ("FMTPTR", %u, %zu)\n",
                                 (uintptr_t)arg, shift, bytes);
         return shary(arg, shift, bytes, &mpz_fdiv_q_2exp);
 }
 
-pointer IntInf_lshift(pointer arg, uint shift, uint bytes) {
+pointer IntInf_lshift(pointer arg, uint shift, size_t bytes) {
         if (DEBUG_INT_INF)
-                fprintf (stderr, "IntInf_lshift ("FMTPTR", %u, %u)\n",
+                fprintf (stderr, "IntInf_lshift ("FMTPTR", %u, %zu)\n",
                                 (uintptr_t)arg, shift, bytes);
         return shary(arg, shift, bytes, &mpz_mul_2exp);
 }
@@ -336,7 +337,7 @@
  * Arg is an intInf, base is the base to use (2, 8, 10 or 16) and space is a
  * string (mutable) which is large enough.
  */
-pointer IntInf_toString (pointer arg, int base, uint bytes) {
+pointer IntInf_toString (pointer arg, int base, size_t bytes) {
         GC_string       sp;
         __mpz_struct    argmpz;
         mp_limb_t       argspace[2];
@@ -346,7 +347,7 @@
         char            c;
 
         if (DEBUG_INT_INF)
-                fprintf (stderr, "IntInf_toString ("FMTPTR", %d, %u)\n",
+                fprintf (stderr, "IntInf_toString ("FMTPTR", %d, %zu)\n",
                                 (uintptr_t)arg, base, bytes);
         assert (base == 2 || base == 8 || base == 10 || base == 16);
         fill (arg, &argmpz, argspace);
@@ -382,7 +383,7 @@
  * num is the numerator bignum, den is the denominator and frontier is
  * the current frontier.
  */
-pointer IntInf_quot (pointer num, pointer den, uint bytes) {
+pointer IntInf_quot (pointer num, pointer den, size_t bytes) {
         __mpz_struct    resmpz,
                         nmpz,
                         dmpz;
@@ -468,7 +469,7 @@
  * num is the numerator bignum, den is the denominator and frontier is
  * the current frontier.
  */
-pointer IntInf_rem (pointer num, pointer den, uint bytes) {
+pointer IntInf_rem (pointer num, pointer den, size_t bytes) {
         __mpz_struct    resmpz,
                         nmpz,
                         dmpz;

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/basis/MLton/rusage.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/basis/MLton/rusage.c	2005-11-15 23:55:59 UTC (rev 4231)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/MLton/rusage.c	2005-11-16 00:33:09 UTC (rev 4232)
@@ -1,7 +1,5 @@
 #include "platform.h"
 
-extern struct GC_state gcState;
-
 static struct rusage self;
 static struct rusage children;
 static struct rusage gc;
@@ -54,8 +52,8 @@
         return gc.ru_stime.tv_usec;
 }
 
-void MLton_Rusage_ru (void) {
-        gc = *(GC_getRusageGCAddr (&gcState));
+void MLton_Rusage_ru (GC_state s) {
+        gc = *(GC_getRusageGCAddr (s));
         getrusage (RUSAGE_SELF, &self);
         getrusage (RUSAGE_CHILDREN, &children);
 }

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/basis/MLton/spawne.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/basis/MLton/spawne.c	2005-11-15 23:55:59 UTC (rev 4231)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/MLton/spawne.c	2005-11-16 00:33:09 UTC (rev 4232)
@@ -28,7 +28,9 @@
         return result;
 }
 #else
-Int MLton_Process_spawne (Pointer p, Pointer a, Pointer e) {
+Int MLton_Process_spawne (__attribute__ ((unused)) Pointer p, 
+                          __attribute__ ((unused)) Pointer a, 
+                          __attribute__ ((unused)) Pointer e) {
         die ("MLton_Process_spawne not implemented");
 }
 #endif

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/basis/MLton/spawnp.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/basis/MLton/spawnp.c	2005-11-15 23:55:59 UTC (rev 4231)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/MLton/spawnp.c	2005-11-16 00:33:09 UTC (rev 4232)
@@ -18,7 +18,8 @@
         return result;
 }
 #else
-Int MLton_Process_spawnp (Pointer p, Pointer a) {
+Int MLton_Process_spawnp (__attribute__ ((unused)) Pointer p, 
+                          __attribute__ ((unused)) Pointer a) {
         die ("MLton_Process_spawnp not implemented");
 }
 #endif

Copied: mlton/branches/on-20050822-x86_64-branch/runtime/basis/Net/Socket/GenericSock.c (from rev 4223, mlton/branches/on-20050822-x86_64-branch/runtime/basis/Net/Socket/Socket.c)
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/basis/Net/Socket/Socket.c	2005-11-15 19:15:14 UTC (rev 4223)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/Net/Socket/GenericSock.c	2005-11-16 00:33:09 UTC (rev 4232)
@@ -0,0 +1,11 @@
+#include "platform.h"
+
+Int GenericSock_socket (Int domain, Int type, Int protocol) {
+        MLton_initSockets ();
+        return socket (domain, type, protocol);
+}
+
+Int GenericSocket_socketPair (Int domain, Int type, Int protocol, Int sv[2]) {
+        MLton_initSockets ();
+        return socketpair (domain, type, protocol, (int*)sv);
+}

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/basis/Net/Socket/Socket.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/basis/Net/Socket/Socket.c	2005-11-15 23:55:59 UTC (rev 4231)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/Net/Socket/Socket.c	2005-11-16 00:33:09 UTC (rev 4232)
@@ -57,16 +57,6 @@
         return shutdown (s, how);
 }
 
-Int GenericSock_socket (Int domain, Int type, Int protocol) {
-        MLton_initSockets ();
-        return socket (domain, type, protocol);
-}
-
-Int Socket_socketPair (Int domain, Int type, Int protocol, Int sv[2]) {
-        MLton_initSockets ();
-        return socketpair (domain, type, protocol, (int*)sv);
-}
-
 Int Socket_Ctl_getSockOpt (Int s, Int level, Int optname, Char *optval,
                                  Int *optlen) {
         MLton_initSockets ();

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/Math.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/Math.c	2005-11-15 23:55:59 UTC (rev 4231)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/Math.c	2005-11-16 00:33:09 UTC (rev 4232)
@@ -1,31 +1,31 @@
 #include "platform.h"
 
 #define unaryReal(f, g)                                         \
-        Real64 Real64_##f (Real64 x) {          \
+        Real64 Real64_##f (Real64 x) {                          \
                 return g (x);                                   \
         }                                                       \
-        Real32 Real32_##f (Real32 x) {          \
+        Real32 Real32_##f (Real32 x) {                          \
                 return (Real32)(Real64_##f ((Real64)x));        \
         }
 unaryReal(abs, fabs)
 unaryReal(round, rint)
 #undef unaryReal
 
-#define binaryReal(f, g)                                                        \
+#define binaryReal(f, g)                                        \
         Real64 Real64_Math_##f (Real64 x, Real64 y) {           \
-                return g (x, y);                                                \
-        }                                                                       \
+                return g (x, y);                                \
+        }                                                       \
         Real32 Real32_Math_##f (Real32 x, Real32 y) {           \
-                return (Real32)(Real64_Math_##f ((Real64)x, (Real64)y));        \
+                return (Real32)(Real64_Math_##f ((Real64)x, (Real64)y)); \
         }
 binaryReal(atan2, atan2)
 #undef binaryReal
 
 #define unaryReal(f, g)                                         \
-        Real64 Real64_Math_##f (Real64 x) {     \
+        Real64 Real64_Math_##f (Real64 x) {                     \
                 return g (x);                                   \
         }                                                       \
-        Real32 Real32_Math_##f (Real32 x) {     \
+        Real32 Real32_Math_##f (Real32 x) {                     \
                 return (Real32)(Real64_Math_##f ((Real64)x));   \
         }
 unaryReal(acos, acos)

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/gdtoa.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/gdtoa.c	2005-11-15 23:55:59 UTC (rev 4231)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/gdtoa.c	2005-11-16 00:33:09 UTC (rev 4232)
@@ -6,7 +6,7 @@
 #endif
 
 /* This code is patterned on g_dfmt from the gdtoa sources. */
-char * Real64_gdtoa (double d, int mode, int ndig, int *decpt) {
+Cstring Real64_gdtoa (double d, int mode, int ndig, int *decpt) {
         ULong bits[2];
         int ex;
         static FPI fpi = { 53, 1-1023-53+1, 2046-1023-53+1, 1, 0 };
@@ -37,10 +37,10 @@
         if (DEBUG)
                 fprintf (stderr, "%s = gdtoa (%g, %d, %d)   decpt = %d\n", 
                                 result, d, mode, ndig, *decpt);
-        return result;
+        return (Cstring)result;
 }
 
-char * Real32_gdtoa (float f, int mode, int ndig, int *decpt) {
+Cstring Real32_gdtoa (float f, int mode, int ndig, int *decpt) {
         ULong bits[1];
         int ex;
         static FPI fpi = { 24, 1-127-24+1,  254-127-24+1, 1, 0 };
@@ -70,5 +70,5 @@
         if (DEBUG)
                 fprintf (stderr, "%s = gdtoa (%g, %d, %d)   decpt = %d\n", 
                                 result, (double)f, mode, ndig, *decpt);
-        return result;
+        return (Cstring)result;
 }

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/modf.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/modf.c	2005-11-15 23:55:59 UTC (rev 4231)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/modf.c	2005-11-16 00:33:09 UTC (rev 4232)
@@ -1,12 +1,12 @@
 #include "platform.h"
 
+Real64 Real64_modf (Real64 x, Real64 *exp) {
+        return modf (x, exp);
+}
+
 Real32 Real32_modf (Real32 x, Real32 *exp) {
         Real64 exp_, res;
         res = modf ((Real64) x, &exp_);
         *exp = (Real32)exp_;
         return (Real32)res;
 }
-
-Real64 Real64_modf (Real64 x, Real64 *exp) {
-        return modf (x, exp);
-}

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/strto.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/strto.c	2005-11-15 23:55:59 UTC (rev 4231)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/strto.c	2005-11-16 00:33:09 UTC (rev 4232)
@@ -3,20 +3,20 @@
 Real32 gdtoa_strtof (char *s, char **endptr);
 Real64 gdtoa_strtod (char *s, char **endptr);
 
-Real32 Real32_strto (char *s) {
+Real32 Real32_strto (Pointer s) {
         char *endptr;
         Real32 res;
 
-        res = gdtoa_strtof (s, &endptr);
+        res = gdtoa_strtof ((char *)s, &endptr);
         assert (NULL != endptr);
         return res;
 }
 
-Real64 Real64_strto (char *s) {
+Real64 Real64_strto (Pointer s) {
         char *endptr;
         Real64 res;
 
-        res = gdtoa_strtod (s, &endptr);
+        res = gdtoa_strtod ((char *)s, &endptr);
         assert (NULL != endptr);
         return res;
 }

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/basis/Stdio.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/basis/Stdio.c	2005-11-15 23:55:59 UTC (rev 4231)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/Stdio.c	2005-11-16 00:33:09 UTC (rev 4232)
@@ -1,12 +1,9 @@
 #include "platform.h"
 
 void Stdio_print (Pointer s) {
-        if (0 == Array_numElements (s))
+        uintmax_t size = GC_getArrayLength (s);
+        if (0 == size)
                 return;
-        while (1 != fwrite (s, Array_numElements(s), 1, stderr))
+        while (1 != fwrite (s, (size_t)size, 1, stderr))
                 /* nothing */;
 }
-
-Int Stdio_sprintf (Pointer buf, Pointer fmt, Real x) {
-        return sprintf ((char*) buf, (char*) fmt, x);
-}

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/invariant.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/invariant.c	2005-11-15 23:55:59 UTC (rev 4231)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/invariant.c	2005-11-16 00:33:09 UTC (rev 4232)
@@ -13,6 +13,19 @@
          "opp = "FMTPTR"  "
          "*opp = "FMTOBJPTR"\n",
          (uintptr_t)opp, *opp);
+  /* The following checks that intergenerational pointers have the
+   * appropriate card marked.  Unfortunately, it doesn't work because
+   * for stacks, the card containing the beginning of the stack is
+   * marked, but any remaining cards aren't.
+   */
+  if (FALSE and s->mutatorMarksCards 
+      and isPointerInOldGen (s, (pointer)opp) 
+      and isObjptrInNursery (s, *opp)
+      and not isCardMarked (s, (pointer)opp)) {
+    displayGCState (s, stderr);
+    die ("gc.c: intergenerational pointer from "FMTPTR" to "FMTOBJPTR" with unmarked card.\n",
+         (uintptr_t)opp, *opp);
+  }
 }
 
 bool invariantForGC (GC_state s) {

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/platform/linux.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/platform/linux.c	2005-11-15 23:55:59 UTC (rev 4231)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/platform/linux.c	2005-11-16 00:33:09 UTC (rev 4232)
@@ -71,11 +71,11 @@
 /*                       Posix                       */
 /* ------------------------------------------------- */
 
-void Posix_IO_setbin (Fd fd) {
+void Posix_IO_setbin (__attribute__ ((unused)) Fd fd) {
         die("Posix_IO_setbin not implemented");
 }
 
-void Posix_IO_settext (Fd fd) {
+void Posix_IO_settext (__attribute__ ((unused)) Fd fd) {
         die("Posix_IO_settext not implemented");
 }
 
@@ -83,6 +83,7 @@
 /*                      Process                      */
 /* ------------------------------------------------- */
 
-Pid MLton_Process_cwait (Pid pid, Pointer status) {
+Pid MLton_Process_cwait (__attribute__ ((unused)) Pid pid, 
+                         __attribute__ ((unused)) Pointer status) {
         die("MLton_Process_cwait not implemented");
 }

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/platform/mmap-protect.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/platform/mmap-protect.c	2005-11-15 23:55:59 UTC (rev 4231)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/platform/mmap-protect.c	2005-11-16 00:33:09 UTC (rev 4232)
@@ -6,10 +6,10 @@
         low = base;
         if (mprotect (low, dead_low, PROT_NONE))
                 diee ("mprotect failed");
-        result = low + dead_low;
+        result = (void*)((pointer)low + dead_low);
         if (mprotect (result, length, PROT_READ | PROT_WRITE | PROT_EXEC))
                 diee ("mprotect failed");
-        high = result + length;
+        high = (void*)((pointer)result + length);
         if (mprotect (high, dead_high, PROT_NONE))
                 diee ("mprotect failed");
         return result;

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/platform.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/platform.c	2005-11-15 23:55:59 UTC (rev 4231)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/platform.c	2005-11-16 00:33:09 UTC (rev 4232)
@@ -22,9 +22,9 @@
   start = GC_init (s, argc, argv);
   /* Setup argv and argc that SML sees. */
   /* start is now the index of the first real arg. */
-  CommandLine_commandName = (uint)(argv[0]);
+  CommandLine_commandName = (unsigned int)(argv[0]);
   CommandLine_argc = argc - start;
-  CommandLine_argv = (uint)(argv + start);
+  CommandLine_argv = (unsigned int)(argv + start);
 }
 
 void MLton_exit (GC_state s, Int status) {

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/platform.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/platform.h	2005-11-15 23:55:59 UTC (rev 4231)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/platform.h	2005-11-16 00:33:09 UTC (rev 4232)
@@ -121,6 +121,13 @@
 #include "types.h"
 
 /* ---------------------------------------------------------------- */
+/*                        Runtime Init/Exit                         */
+/* ---------------------------------------------------------------- */
+
+void MLton_init (int argc, char **argv, GC_state s);
+void MLton_exit (GC_state s, Int status) __attribute__ ((noreturn));
+
+/* ---------------------------------------------------------------- */
 /*                        Utility libraries                         */
 /* ---------------------------------------------------------------- */
 
@@ -171,13 +178,6 @@
 /* ---------------------------------------------------------------- */
 
 /* ------------------------------------------------- */
-/*                       Array                       */
-/* ------------------------------------------------- */
-
-#define Array_maxLen GC_MAX_ARRAY_LENGTH
-Int Array_numElements (Pointer p);
-
-/* ------------------------------------------------- */
 /*                    CommandLine                    */
 /* ------------------------------------------------- */
 
@@ -250,20 +250,20 @@
  * into the array used for allocation profiling, and the appropriate element
  * is incremented by the amount that the function moves the frontier.
  */
-Pointer IntInf_add (Pointer lhs, Pointer rhs, uint bytes);
-Pointer IntInf_andb (Pointer lhs, Pointer rhs, uint bytes);
-Pointer IntInf_arshift (Pointer arg, uint shift, uint bytes);
-Pointer IntInf_gcd (Pointer lhs, Pointer rhs, uint bytes);
-Pointer IntInf_lshift (Pointer arg, uint shift, uint bytes);
-Pointer IntInf_mul (Pointer lhs, Pointer rhs, uint bytes);
-Pointer IntInf_neg (Pointer arg, uint bytes);
-Pointer IntInf_notb (Pointer arg, uint bytes);
-Pointer IntInf_orb (Pointer lhs, Pointer rhs, uint bytes);
-Pointer IntInf_quot (Pointer num, Pointer den, uint bytes);
-Pointer IntInf_rem (Pointer num, Pointer den, uint bytes);
-Pointer IntInf_sub (Pointer lhs, Pointer rhs, uint bytes);
-Pointer IntInf_toString (Pointer arg, int base, uint bytes);
-Pointer IntInf_xorb (Pointer lhs, Pointer rhs, uint bytes);
+Pointer IntInf_add (Pointer lhs, Pointer rhs, size_t bytes);
+Pointer IntInf_andb (Pointer lhs, Pointer rhs, size_t bytes);
+Pointer IntInf_arshift (Pointer arg, uint shift, size_t bytes);
+Pointer IntInf_gcd (Pointer lhs, Pointer rhs, size_t bytes);
+Pointer IntInf_lshift (Pointer arg, uint shift, size_t bytes);
+Pointer IntInf_mul (Pointer lhs, Pointer rhs, size_t bytes);
+Pointer IntInf_neg (Pointer arg, size_t bytes);
+Pointer IntInf_notb (Pointer arg, size_t bytes);
+Pointer IntInf_orb (Pointer lhs, Pointer rhs, size_t bytes);
+Pointer IntInf_quot (Pointer num, Pointer den, size_t bytes);
+Pointer IntInf_rem (Pointer num, Pointer den, size_t bytes);
+Pointer IntInf_sub (Pointer lhs, Pointer rhs, size_t bytes);
+Pointer IntInf_toString (Pointer arg, int base, size_t bytes);
+Pointer IntInf_xorb (Pointer lhs, Pointer rhs, size_t bytes);
 
 Word IntInf_smallMul (Word lhs, Word rhs, Pointer carry);
 Int IntInf_compare (Pointer lhs, Pointer rhs);
@@ -285,11 +285,10 @@
 /*                       MLton                       */
 /* ------------------------------------------------- */
 
+void MLton_allocTooLarge (void) __attribute__ ((noreturn));
 /* print a bug message and exit (2) */
-void MLton_bug (Pointer msg);
+void MLton_bug (Pointer msg) __attribute__ ((noreturn));
 
-Int MLton_errno (void);
-
 /* ---------------------------------- */
 /*           MLton.Platform           */
 /* ---------------------------------- */
@@ -372,7 +371,61 @@
 Rlimit MLton_Rlimit_getSoft (void);
 Int MLton_Rlimit_set (Resource r, Rlimit hard, Rlimit soft);
 
+/* ---------------------------------- */
+/*           MLton.Rusage             */
+/* ---------------------------------- */
+
+Int MLton_Rusage_self_utime_sec (void);
+Int MLton_Rusage_self_utime_usec (void);
+Int MLton_Rusage_self_stime_sec (void);
+Int MLton_Rusage_self_stime_usec (void);
+Int MLton_Rusage_children_utime_sec (void);
+Int MLton_Rusage_children_utime_usec (void);
+Int MLton_Rusage_children_stime_sec (void);
+Int MLton_Rusage_children_stime_usec (void);
+Int MLton_Rusage_gc_utime_sec (void);
+Int MLton_Rusage_gc_utime_usec (void);
+Int MLton_Rusage_gc_stime_sec (void);
+Int MLton_Rusage_gc_stime_usec (void);
+void MLton_Rusage_ru (GC_state s);
+
 /* ------------------------------------------------- */
+/*                        Net                        */
+/* ------------------------------------------------- */
+
+Int Net_htonl (Int i);
+Int Net_ntohl (Int i);
+Int Net_htons (Int i);
+Int Net_ntohs (Int i);
+#define NetHostDB_inAddrLen sizeof (struct in_addr)
+#define NetHostDB_INADDR_ANY INADDR_ANY
+Cstring NetHostDB_Entry_name(void);
+Int NetHostDB_Entry_numAliases(void);
+Cstring NetHostDB_Entry_aliasesN(Int n);
+Int NetHostDB_Entry_addrType(void);
+Int NetHostDB_Entry_length(void);
+Int NetHostDB_Entry_numAddrs(void);
+void NetHostDB_Entry_addrsN(Int n, Pointer addr);
+Bool NetHostDB_getByAddress(Pointer addr, Int len);
+Bool NetHostDB_getByName(Cstring name);
+Int NetHostDB_getHostName(Pointer buf, Int len);
+Cstring NetProtDB_Entry_name(void);
+Int NetProtDB_Entry_numAliases(void);
+Cstring NetProtDB_Entry_aliasesN(Int n);
+Int NetProtDB_Entry_protocol(void);
+Int NetProtDB_getByName(Cstring name);
+Int NetProtDB_getByNumber(Int proto);
+Cstring NetServDB_Entry_name(void);
+Int NetServDB_Entry_numAliases(void);
+Cstring NetServDB_Entry_aliasesN(Int n);
+Int NetServDB_Entry_port(void);
+Cstring NetServDB_Entry_protocol(void);
+Int NetServDB_getByName(Cstring name, Cstring proto);
+Int NetServDB_getByNameNull(Cstring name);
+Int NetServDB_getByPort(Int port, Cstring proto);
+Int NetServDB_getByPortNull(Int port);
+
+/* ------------------------------------------------- */
 /*                      OS                           */
 /* ------------------------------------------------- */
 
@@ -387,8 +440,14 @@
 /*                     PackReal                      */
 /* ------------------------------------------------- */
 
-Real64 PackReal_subVec (Pointer v, Int offset);
-void PackReal_update (Pointer a, Int offset, Real64 r);
+Real32 PackReal32_subVec (Pointer v, Int offset);
+Real32 PackReal32_subVecRev (Pointer v, Int offset);
+Real64 PackReal64_subVec (Pointer v, Int offset);
+Real64 PackReal64_subVecRev (Pointer v, Int offset);
+void PackReal32_update (Pointer a, Int offset, Real32 r);
+void PackReal32_updateRev (Pointer a, Int offset, Real32 r);
+void PackReal64_update (Pointer a, Int offset, Real64 r);
+void PackReal64_updateRev (Pointer a, Int offset, Real64 r);
 
 /* ------------------------------------------------- */
 /*                       Posix                       */
@@ -399,7 +458,7 @@
 /* ---------------------------------- */
 
 void Posix_Error_clearErrno (void);
-Int Posix_Error_gettErrno (void);
+int Posix_Error_getErrno (void);
 Cstring Posix_Error_strerror (Int n);
 
 #define Posix_Error_acces EACCES
@@ -542,7 +601,7 @@
 #endif
 
 Int Posix_FileSys_Dirstream_closedir (Cpointer d);
-Cpointer Posix_FileSys_DirStream_opendir (Pointer p);
+Cpointer Posix_FileSys_Dirstream_opendir (Pointer p);
 Cstring Posix_FileSys_Dirstream_readdir (Cpointer d);
 void Posix_FileSys_Dirstream_rewinddir (Cpointer p);
 
@@ -565,6 +624,16 @@
 void Posix_FileSys_Utimbuf_setModTime (Int x);
 Int Posix_FileSys_Utimbuf_utime (Pointer s);
 
+Int Posix_FileSys_access (Pointer f, Word w);
+Int Posix_FileSys_chdir(Pointer p);
+Int Posix_FileSys_chmod (Pointer p, Mode m);
+Int Posix_FileSys_chown (Pointer p, Uid u, Gid g);
+Int Posix_FileSys_fchmod (Fd f, Mode m);
+Int Posix_FileSys_fchown (Fd f, Uid u, Gid g);
+Int Posix_FileSys_fpathconf (Fd f, Int n);
+Int Posix_FileSys_ftruncate (Fd f, Position n);
+Cstring Posix_FileSys_getcwd (Pointer buf, Size n);
+Int Posix_FileSys_link (Pointer p1, Pointer p2);
 Int Posix_FileSys_mkdir (Pointer p, Word w);
 Int Posix_FileSys_mkfifo (Pointer p, Word w);
 Int Posix_FileSys_open (Pointer p, Word w, Mode m);
@@ -676,6 +745,7 @@
 Int Posix_ProcEnv_setuid (Uid u);
 Int Posix_ProcEnv_setgid (Gid g);
 Int Posix_ProcEnv_getgroups (Pointer groups);
+Int Posix_ProcEnv_setgroups (Pointer groups);
 Cstring Posix_ProcEnv_getlogin (void);
 Pid Posix_ProcEnv_getpgrp (void);
 Pid Posix_ProcEnv_setsid (void);
@@ -733,11 +803,13 @@
 Int Posix_Process_alarm (Int i);
 Int Posix_Process_exece (Pointer path, Pointer args, Pointer env);
 Int Posix_Process_execp (Pointer file, Pointer args);
-void Posix_Process_exit (Int i);
+void Posix_Process_exit (Int i) __attribute__ ((noreturn));
 Pid Posix_Process_fork (void);
 Int Posix_Process_kill (Pid p, Signal s);
+Int Posix_Process_nanosleep (Pointer sec, Pointer nsec);
 Int Posix_Process_pause (void);
 Int Posix_Process_sleep (Int i);
+int Posix_Process_system (const char* cmd);
 Pid Posix_Process_waitpid (Pid p, Pointer s, Int i);
 Bool Posix_Process_ifExited (Status s);
 Int Posix_Process_exitStatus (Status s);
@@ -761,16 +833,21 @@
 #define Posix_Signal_setmask SIG_SETMASK
 #define Posix_Signal_unblock SIG_UNBLOCK
 Int Posix_Signal_default (Int signum);
+bool Posix_Signal_isGCPending (void);
+Bool Posix_Signal_isPending (Int signum);
 Int Posix_Signal_handle (Int signum);
+void Posix_Signal_handleGC (void);
 Int Posix_Signal_ignore (Int signum);
 Int Posix_Signal_isDefault (Int signum, Bool *isDef);
-Bool Posix_Signal_isPending (Int signum);
+void Posix_Signal_resetPending (void);
+
 Int Posix_Signal_sigaddset (Int signum);
 Int Posix_Signal_sigdelset (Int signum);
 Int Posix_Signal_sigemptyset (void);
 Int Posix_Signal_sigfillset (void);
+Int Posix_Signal_sigismember (Int signum);
 Int Posix_Signal_sigprocmask (Int how);
-Int Posix_Signal_sigsuspend (void);
+void Posix_Signal_suspend (void);
 
 /* ---------------------------------- */
 /*            Posix.SysDB             */
@@ -895,6 +972,58 @@
 Int Ptrace_ptrace4 (Int request, Int pid, Word addr, Pointer data);
 
 /* ------------------------------------------------- */
+/*                       Real                        */
+/* ------------------------------------------------- */
+
+Real64 Real64_modf (Real64 x, Real64 *exp);
+Real32 Real32_modf (Real32 x, Real32 *exp);
+#define unaryReal(f)                                            \
+  Real64 Real64_##f (Real64 x);                                 \
+  Real32 Real32_##f (Real32 x);
+unaryReal(abs)
+unaryReal(round)
+#undef unaryReal
+#define binaryReal(f)                                           \
+        Real64 Real64_Math_##f (Real64 x, Real64 y);            \
+        Real32 Real32_Math_##f (Real32 x, Real32 y);
+binaryReal(atan2)
+#undef binaryReal
+#define unaryReal(f)                                            \
+        Real64 Real64_Math_##f (Real64 x);                      \
+        Real32 Real32_Math_##f (Real32 x);
+unaryReal(acos)
+unaryReal(asin)
+unaryReal(atan)
+unaryReal(cos)
+unaryReal(exp)
+unaryReal(ln)
+unaryReal(log10)
+unaryReal(sin)
+unaryReal(sqrt)
+unaryReal(tan)
+#undef unaryReal
+Real64 Real64_ldexp (Real64 x, Int32 i);
+Real32 Real32_ldexp (Real32 x, Int32 i);
+Real64 Real64_frexp (Real64 x, Int *exp);
+Cstring Real64_gdtoa (double d, int mode, int ndig, int *decpt);
+Cstring Real32_gdtoa (float f, int mode, int ndig, int *decpt);
+Int Real32_class (Real32 f);
+Int Real64_class (Real64 d);
+Real32 Real32_strto (Pointer s);
+Real64 Real64_strto (Pointer s);
+Real64 Real64_nextAfter (Real64 x1, Real64 x2);
+Int Real32_signBit (Real32 f);
+Int Real64_signBit (Real64 d);
+#define ternary(size, name)                                     \
+        Real##size Real##size##_mul##name                       \
+                (Real##size r1, Real##size r2, Real##size r3);
+ternary(32, add)
+ternary(64, add)
+ternary(32, sub)
+ternary(64, sub)
+#undef ternary
+
+/* ------------------------------------------------- */
 /*                      Socket                       */
 /* ------------------------------------------------- */
 
@@ -904,8 +1033,6 @@
 static inline void MLton_initSockets (void) {}
 #endif
 
-#define NetHostDB_inAddrLen sizeof (struct in_addr)
-#define NetHostDB_INADDR_ANY INADDR_ANY
 #define Socket_sockAddrLenMax max(sizeof (struct sockaddr), \
                               max(sizeof (struct sockaddr_un), \
                               max(sizeof (struct sockaddr_in), \
@@ -940,13 +1067,37 @@
 #define Socket_MSG_PEEK MSG_PEEK
 #define Socket_INetSock_TCP_SOL_TCP IPPROTO_TCP
 #define Socket_INetSock_TCP_SO_NODELAY TCP_NODELAY
+Int Socket_accept (Int s, Char *addr, Int *addrlen);
+Int Socket_bind (Int s, Char *addr, Int addrlen);
+Int Socket_close(Int s);
+Int Socket_connect (Int s, Char *addr, Int addrlen);
+Int Socket_familyOfAddr(Char *addr);
+Int Socket_listen (Int s, Int backlog);
+Int Socket_recv (Int s, Char *msg, Int start, Int len, Word flags);
+Int Socket_recvFrom (Int s, Char *msg, Int start, Int len, Word flags, Char* addr, Int *addrlen);
+Int Socket_send (Int s, Char *msg, Int start, Int len, Word flags);
+Int Socket_sendTo (Int s, Char *msg, Int start, Int len, Word flags, Char* addr, Int addrlen);
+Int Socket_shutdown (Int s, Int how);
+Int Socket_Ctl_getSockOpt (Int s, Int level, Int optname, Char *optval, Int *optlen);
+Int Socket_Ctl_setSockOpt (Int s, Int level, Int optname, Char *optval, Int optlen);
+Int Socket_Ctl_getsetIOCtl (Int s, Int request, Char* argp);
+Int Socket_Ctl_getPeerName (Int s, Char *name, Int *namelen);
+Int Socket_Ctl_getSockName (Int s, Char *name, Int *namelen);
+Int GenericSock_socket (Int domain, Int type, Int protocol);
+Int GenericSocket_socketPair (Int domain, Int type, Int protocol, Int sv[2]);
+void UnixSock_toAddr (Char* path, Int pathlen, Char* addr, Int *addrlen);
+Int UnixSock_pathLen (Char* addr);
+void UnixSock_fromAddr (Char* addr, Char* path, Int pathlen);
+void INetSock_toAddr (Pointer in_addr, Int port, Char* addr, Int *addrlen);
+void INetSock_fromAddr (Char* addr);
+Int INetSock_getPort (void);
+void INetSock_getInAddr (Pointer addr);
 
 /* ------------------------------------------------- */
 /*                       Stdio                       */
 /* ------------------------------------------------- */
 
 void Stdio_print (Pointer s);
-Int Stdio_sprintf (Pointer buf, Pointer fmt, Real64 x);
 
 /* ------------------------------------------------- */
 /*                      String                       */
@@ -969,15 +1120,101 @@
 Int Windows_terminate (Pid p, Int s);
 
 /* ------------------------------------------------- */
-/*                       Word8                       */
+/*                  Word{8,16,32,64}                 */
 /* ------------------------------------------------- */
 
-Char Word8_arshiftAsm (Char w, Word s);
+#define coerce(f, t)                            \
+        t f##_to##t (f x);
+#define bothCoerce(from, to)                    \
+        coerce (Word##S##from, Word##to)        \
+        coerce (Word##U##from, Word##to)
+#define binary(kind, name)                                              \
+        Word##kind Word##kind##_##name (Word##kind w1, Word##kind w2);
+#define bothBinary(size, name)                  \
+        binary (S##size, name)                  \
+        binary (U##size, name)
+#define SaddCheckOverflows(size)                                        \
+        Bool WordS##size##_addCheckOverflows (WordS##size x, WordS##size y);
+#define UaddCheckOverflows(size)                                        \
+        Bool WordU##size##_addCheckOverflows (WordU##size x, WordU##size y);
+#define SmulCheckOverflows(size)                                        \
+        Bool WordS##size##_mulCheckOverflows (WordS##size x, WordS##size y);
+#define negCheckOverflows(size)                                         \
+        Bool Word##size##_negCheckOverflows (WordS##size x);
+#define SsubCheckOverflows(size)                                        \
+        Bool WordS##size##_subCheckOverflows (WordS##size x, WordS##size y);
+#define compare(kind, name)                                             \
+        Bool Word##kind##_##name (Word##kind w1, Word##kind w2);
+#define bothCompare(size, name)                     \
+        compare (S##size, name)                     \
+        compare (U##size, name)    
+#define unary(kind, name)                           \
+        Word##kind Word##kind##_##name (Word##kind w);
+#define shift(kind, name)                                               \
+        Word##kind Word##kind##_##name (Word##kind w1, Word w2);
 
+#define all(size)                                               \
+        binary (size, add)                                      \
+        SaddCheckOverflows (size)                               \
+        UaddCheckOverflows (size)                               \
+        binary (size, andb)                                     \
+        compare (size, equal)                                   \
+        bothCompare (size, ge)                                  \
+        bothCompare (size, gt)                                  \
+        bothCompare (size, le)                                  \
+        shift (size, lshift)                                    \
+        bothCompare (size, lt)                                  \
+        bothBinary (size, mul)                                  \
+        unary (size, neg)                                       \
+        negCheckOverflows (size)                                \
+        unary (size, notb)                                      \
+        binary (size, orb)                                      \
+        bothBinary (size, quot)                                 \
+        SmulCheckOverflows (size)                               \
+        bothBinary (size, rem)                                  \
+        Word##size Word##size##_rol (Word##size w1, Word w2);   \
+        Word##size Word##size##_ror (Word##size w1, Word w2);   \
+        shift (S##size, rshift)                                 \
+        shift (U##size, rshift)                                 \
+        binary (size, sub)                                      \
+        SsubCheckOverflows (size)                               \
+        binary (size, xorb)                                     \
+        bothCoerce (size, 64)                                   \
+        bothCoerce (size, 32)                                   \
+        bothCoerce (size, 16)                                   \
+        bothCoerce (size, 8)
+
+all (8)
+all (16)
+all (32)
+all (64)
+
+#undef coerce
+#undef bothCoerce
+#undef binary
+#undef bothBinary
+#undef SaddCheckOverflows
+#undef UaddCheckOverflows
+#undef SmulCheckOverflows
+#undef negCheckOverflows
+#undef SsubCheckOverflows
+#undef compare
+#undef bothCompare
+#undef unary
+#undef shift
+#undef all
+
 /* ------------------------------------------------- */
-/*                      Word32                       */
+/*                    Word8 Array                    */
 /* ------------------------------------------------- */
 
-Word Word32_arshiftAsm (Word w, Word s);
+Word32 Word8Array_subWord32Rev (Pointer v, Int offset);
+void Word8Array_updateWord32Rev (Pointer a, Int offset, Word32 w);
 
+/* ------------------------------------------------- */
+/*                    Word8 Vector                   */
+/* ------------------------------------------------- */
+
+Word32 Word8Vector_subWord32Rev (Pointer v, Int offset);
+
 #endif /* _MLTON_PLATFORM_H_ */