[MLton-commit] r4171

Matthew Fluet MLton@mlton.org
Mon, 7 Nov 2005 18:59:39 -0800


Working towards reintegration of revised GC.

Somewhat working.  Still seems to be some issues with signals and with
pack-real.


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

U   mlton/branches/on-20050822-x86_64-branch/Makefile
U   mlton/branches/on-20050822-x86_64-branch/basis-library/misc/primitive.sml
U   mlton/branches/on-20050822-x86_64-branch/basis-library/mlton/signal.sml
U   mlton/branches/on-20050822-x86_64-branch/basis-library/mlton/thread.sig
U   mlton/branches/on-20050822-x86_64-branch/basis-library/mlton/thread.sml
U   mlton/branches/on-20050822-x86_64-branch/bytecode/interpret.c
U   mlton/branches/on-20050822-x86_64-branch/include/bytecode-main.h
U   mlton/branches/on-20050822-x86_64-branch/include/c-main.h
U   mlton/branches/on-20050822-x86_64-branch/include/main.h
U   mlton/branches/on-20050822-x86_64-branch/include/x86-main.h
U   mlton/branches/on-20050822-x86_64-branch/mlton/backend/ssa-to-rssa.fun
U   mlton/branches/on-20050822-x86_64-branch/mlton/codegen/c-codegen/c-codegen.fun
U   mlton/branches/on-20050822-x86_64-branch/mlton/main/compile.fun
U   mlton/branches/on-20050822-x86_64-branch/mlton/main/lookup-constant.fun
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/Stat.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/Utimbuf.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/access.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/chdir.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/chmod.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/chown.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/link.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/mkdir.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/mkfifo.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/open.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/pathconf.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/readlink.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/rename.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/rmdir.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/symlink.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/unlink.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/setenv.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/Posix/ProcEnv/setgroups.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/Posix/Process/exece.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/Posix/Process/execp.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/Posix/SysDB/Group.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/basis/Date.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/basis/IntInf.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
U   mlton/branches/on-20050822-x86_64-branch/runtime/basis/MLton/thread.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/frexp.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/cenv.h
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/TODO
A   mlton/branches/on-20050822-x86_64-branch/runtime/gc/align.h
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/cheney-copy.c
D   mlton/branches/on-20050822-x86_64-branch/runtime/gc/debug.c
A   mlton/branches/on-20050822-x86_64-branch/runtime/gc/debug.h
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/exports.h
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/foreach.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/forward.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/garbage-collection.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/generational.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/handler.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/handler.h
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/heap.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/init-world.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/init.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/init.h
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/int-inf.h
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/new-object.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/object.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/object.h
A   mlton/branches/on-20050822-x86_64-branch/runtime/gc/platform.h
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/profiling.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/profiling.h
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/signals.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/sources.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/switch-thread.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/thread.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/virtual-memory.c
D   mlton/branches/on-20050822-x86_64-branch/runtime/gc/virtual-memory.h
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/weak.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/world.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/world.h
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc.h
A   mlton/branches/on-20050822-x86_64-branch/runtime/gen/
A   mlton/branches/on-20050822-x86_64-branch/runtime/gen/gen-types.c
A   mlton/branches/on-20050822-x86_64-branch/runtime/platform/displayMem.linux.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/platform/getText.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/platform/linux.c
A   mlton/branches/on-20050822-x86_64-branch/runtime/platform/mmap-protect.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/platform/mmap.c
D   mlton/branches/on-20050822-x86_64-branch/runtime/platform/ssmmap.c
A   mlton/branches/on-20050822-x86_64-branch/runtime/platform/sysconf.c
D   mlton/branches/on-20050822-x86_64-branch/runtime/platform/totalRam.sysconf.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/platform/use-mmap.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/platform.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/platform.h
D   mlton/branches/on-20050822-x86_64-branch/runtime/types.h
U   mlton/branches/on-20050822-x86_64-branch/runtime/util.h

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

Modified: mlton/branches/on-20050822-x86_64-branch/Makefile
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/Makefile	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/Makefile	2005-11-08 02:59:15 UTC (rev 4171)
@@ -276,8 +276,12 @@
 	$(MAKE) -C runtime
 	$(CP) $(RUN)/*.a $(LIB)/$(TARGET)/
 	$(CP) runtime/*.h include/*.h $(INC)/
+	mkdir -p $(INC)/gc
+	mkdir -p $(INC)/util
 	mkdir -p $(INC)/platform
 	$(CP) bytecode/interpret.h $(INC)
+	$(CP) runtime/gc/*.h $(INC)/gc
+	$(CP) runtime/util/*.h $(INC)/util
 	$(CP) runtime/platform/*.h $(INC)/platform
 	$(MAKE) -C bytecode
 	bytecode/print-opcodes >$(LIB)/opcodes

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-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/misc/primitive.sml	2005-11-08 02:59:15 UTC (rev 4171)
@@ -1705,15 +1705,15 @@
              *)
             val copyCurrent = _prim "Thread_copyCurrent": unit -> unit;
             val current = _import "Thread_current": unit -> thread;
-            val finishHandler = _import "Thread_finishHandler": unit -> unit;
+            val finishSignalHandler = _import "Thread_finishSignalHandler": unit -> unit;
             val returnToC = _prim "Thread_returnToC": unit -> unit;
             val saved = _import "Thread_saved": unit -> thread;
             val savedPre = _import "Thread_saved": unit -> preThread;
             val setCallFromCHandler =
                _import "Thread_setCallFromCHandler": thread -> unit;
-            val setHandler = _import "Thread_setHandler": thread -> unit;
+            val setSignalHandler = _import "Thread_setSignalHandler": thread -> unit;
             val setSaved = _import "Thread_setSaved": thread -> unit;
-            val startHandler = _import "Thread_startHandler": unit -> unit;
+            val startSignalHandler = _import "Thread_startSignalHandler": unit -> unit;
             val switchTo = _prim "Thread_switchTo": thread -> unit;
          end      
 

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library/mlton/signal.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library/mlton/signal.sml	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/mlton/signal.sml	2005-11-08 02:59:15 UTC (rev 4171)
@@ -172,7 +172,7 @@
                          end)
 
             val () =
-               MLtonThread.setHandler
+               MLtonThread.setSignalHandler
                (fn t =>
                 let
                    val mask = Mask.getBlocked ()
@@ -221,7 +221,7 @@
 fun suspend m =
    (Mask.write m
     ; Prim.suspend ()
-    ; MLtonThread.switchToHandler ())
+    ; MLtonThread.switchToSignalHandler ())
 
 fun handleGC f =
    (Prim.handleGC ()

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library/mlton/thread.sig
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library/mlton/thread.sig	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/mlton/thread.sig	2005-11-08 02:59:15 UTC (rev 4171)
@@ -63,6 +63,6 @@
 
       val amInSignalHandler: unit -> bool
       val register: int * (unit -> unit) -> unit
-      val setHandler: (Runnable.t -> Runnable.t) -> unit
-      val switchToHandler: unit -> unit
+      val setSignalHandler: (Runnable.t -> Runnable.t) -> unit
+      val switchToSignalHandler: unit -> unit
    end

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library/mlton/thread.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library/mlton/thread.sml	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/mlton/thread.sml	2005-11-08 02:59:15 UTC (rev 4171)
@@ -163,7 +163,7 @@
 in
    fun amInSignalHandler () = InHandler = !state
 
-   fun setHandler (f: Runnable.t -> Runnable.t): unit =
+   fun setSignalHandler (f: Runnable.t -> Runnable.t): unit =
       let
          val _ = Primitive.installSignalHandler ()
          fun loop (): unit =
@@ -172,7 +172,7 @@
                val _ = state := InHandler
                val t = f (fromPrimitive (Prim.saved ()))
                val _ = state := Normal
-               val _ = Prim.finishHandler ()
+               val _ = Prim.finishSignalHandler ()
                val _ =
                   atomicSwitch
                   (fn (T r) =>
@@ -180,7 +180,7 @@
                       val _ =
                          case !r of
                             Paused (f, _) => f (fn () => ())
-                          | _ => raise die "Thread.setHandler saw strange thread"
+                          | _ => raise die "Thread.setSignalHandler saw strange thread"
                    in
                       t
                    end) (* implicit atomicEnd () *)
@@ -192,15 +192,15 @@
             (new (fn () => loop () handle e => MLtonExn.topLevelHandler e))
          val _ = signalHandler := SOME p
       in
-         Prim.setHandler p
+         Prim.setSignalHandler p
       end
 
-   fun switchToHandler () =
+   fun switchToSignalHandler () =
       let
          (* Atomic 0 *)
          val () = atomicBegin ()
          (* Atomic 1 *)
-         val () = Prim.startHandler () (* implicit atomicBegin () *)
+         val () = Prim.startSignalHandler () (* implicit atomicBegin () *)
          (* Atomic 2 *)
       in
          case !signalHandler of

Modified: mlton/branches/on-20050822-x86_64-branch/bytecode/interpret.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/bytecode/interpret.c	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/bytecode/interpret.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -5,14 +5,17 @@
  * See the file MLton-LICENSE for details.
  */
 
+#define MLTON_GC_INTERNAL
 #include "platform.h"
+#undef MLTON_GC_INTERNAL
+
 #include "interpret.h"
 #include "c-chunk.h"    // c-chunk.h must come before opcode.h because it
                         // redefines some opcode symbols
 #include "opcode.h"
 
 enum {
-        DEBUG = FALSE,
+  DEBUG_BYTECODE = FALSE,
 };
 
 typedef Word32 ArrayIndex;
@@ -75,7 +78,7 @@
 #define Fetch(t, z)                                                             \
         do {                                                                    \
                 z = *(t*)pc;                                                    \
-                if (DEBUG or disassemble) {                                     \
+                if (DEBUG or DEBUG_BYTECODE or disassemble) {                   \
                         if (#z == "label")                                      \
                                 fprintf (stderr, " %s", offsetToLabel[z]);      \
                         else if (#z != "opc")                                   \
@@ -318,10 +321,10 @@
                 assertRegsEmpty ();                                     \
                 while (pc < lastCase) {                                 \
                         Word##size caseWord;                            \
-                        if (DEBUG or disassemble)                       \
+                        if (DEBUG or DEBUG_BYTECODE or disassemble)     \
                                 fprintf (stderr, "\n\t  ");             \
                         Fetch (Word##size, caseWord);                   \
-                        if (DEBUG or disassemble)                       \
+                        if (DEBUG or DEBUG_BYTECODE or disassemble)     \
                                 fprintf (stderr, " =>");                \
                         Fetch (Label, label);                           \
                         if (not disassemble and test == caseWord)       \
@@ -376,8 +379,9 @@
 
         code = b->code;
         pcMax = b->code + b->codeSize;
-        if (DEBUG or disassemble) {
-                ARRAY (String*, offsetToLabel, b->codeSize);
+        if (DEBUG or DEBUG_BYTECODE or disassemble) {
+                offsetToLabel =
+                  (String*)(calloc_safe (b->codeSize, sizeof(*offsetToLabel)));
                 for (i = 0; i < b->nameOffsetsSize; ++i)
                         offsetToLabel [b->nameOffsets[i].codeOffset] =
                                 b->addressNames + b->nameOffsets[i].nameOffset;
@@ -391,7 +395,7 @@
 mainLoop:
         if (FALSE)
                 displayRegs ();
-        if (DEBUG or disassemble) {
+        if (DEBUG or DEBUG_BYTECODE or disassemble) {
                 if (pc == pcMax)
                         goto done;
                 name = offsetToLabel [pc - b->code];
@@ -401,8 +405,8 @@
         }
         assert (code <= pc and pc < pcMax);
         Fetch (Opcode, opc);
-        assert (opc < cardof (opcodeStrings));
-        if (DEBUG or disassemble)
+        assert (opc < (cardof (opcodeStrings)));
+        if (DEBUG or DEBUG_BYTECODE or disassemble)
                 fprintf (stderr, "%s", opcodeStrings[opc]);
         switch (opc) {
         prims ();
@@ -456,7 +460,7 @@
         }
         assert (FALSE);
 done:
-        if (DEBUG or disassemble)
+        if (DEBUG or DEBUG_BYTECODE or disassemble)
                 free (offsetToLabel);
         return;
 }
@@ -467,7 +471,7 @@
 }
 
 void MLton_Bytecode_interpret (Bytecode b, Word32 codeOffset) {
-        if (DEBUG) {
+        if (DEBUG or DEBUG_BYTECODE) {
                 fprintf (stderr, "MLton_Bytecode_interpret (0x%08x, %u)\n",
                                 (uint)b,
                                 (uint)codeOffset);

Modified: mlton/branches/on-20050822-x86_64-branch/include/bytecode-main.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/include/bytecode-main.h	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/include/bytecode-main.h	2005-11-08 02:59:15 UTC (rev 4171)
@@ -33,7 +33,7 @@
         s->canHandle += 3;                                              \
         /* Switch to the C Handler thread. */                           \
         GC_switchToThread (s, s->callFromCHandler, 0);                  \
-        nextFun = *(int*)(s->stackTop - WORD_SIZE);                     \
+        nextFun = *(int*)(s->stackTop - GC_RETURNADDRESS_SIZE);         \
         MLton_Bytecode_interpret (&MLton_bytecode, nextFun);            \
         GC_switchToThread (s, s->savedThread, 0);                       \
         s->savedThread = BOGUS_THREAD;                                  \
@@ -48,7 +48,7 @@
                 nextFun = ml;                                           \
         } else {                                                        \
                 /* Return to the saved world */                         \
-                nextFun = *(int*)(gcState.stackTop - WORD_SIZE);        \
+                nextFun = *(int*)(gcState.stackTop - GC_RETURNADDRESS_SIZE); \
         }                                                               \
         MLton_Bytecode_interpret (&MLton_bytecode, nextFun);            \
 }

Modified: mlton/branches/on-20050822-x86_64-branch/include/c-main.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/include/c-main.h	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/include/c-main.h	2005-11-08 02:59:15 UTC (rev 4171)
@@ -28,29 +28,29 @@
                 fprintf (stderr, "MLton_callFromC() starting\n");       \
         s = &gcState;                                                   \
         s->savedThread = s->currentThread;                              \
-        s->canHandle += 3;                                              \
+        s->atomicState += 3;                                            \
         /* Switch to the C Handler thread. */                           \
-        GC_switchToThread (s, s->callFromCHandler, 0);                  \
-        nextFun = *(int*)(s->stackTop - WORD_SIZE);                     \
+        GC_switchToThread (s, s->callFromCHandlerThread, 0);            \
+        nextFun = *(int*)(s->stackTop - GC_RETURNADDRESS_SIZE);         \
         cont.nextChunk = nextChunks[nextFun];                           \
         returnToC = FALSE;                                              \
         do {                                                            \
                 cont=(*(struct cont(*)(void))cont.nextChunk)();         \
         } while (not returnToC);                                        \
         GC_switchToThread (s, s->savedThread, 0);                       \
-        s->savedThread = BOGUS_THREAD;                                  \
+        s->savedThread = BOGUS_OBJPTR;                                  \
         if (DEBUG_CCODEGEN)                                             \
                 fprintf (stderr, "MLton_callFromC done\n");             \
 }                                                                       \
 int main (int argc, char **argv) {                                      \
         struct cont cont;                                               \
         Initialize (al, mg, mfs, mmc, pk, ps);                          \
-        if (gcState.isOriginal) {                                       \
+        if (gcState.amOriginal) {                                       \
                 real_Init();                                            \
                 PrepFarJump(mc, ml);                                    \
         } else {                                                        \
                 /* Return to the saved world */                         \
-                nextFun = *(int*)(gcState.stackTop - WORD_SIZE);        \
+                nextFun = *(int*)(gcState.stackTop - GC_RETURNADDRESS_SIZE); \
                 cont.nextChunk = nextChunks[nextFun];                   \
         }                                                               \
         /* Trampoline */                                                \

Modified: mlton/branches/on-20050822-x86_64-branch/include/main.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/include/main.h	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/include/main.h	2005-11-08 02:59:15 UTC (rev 4171)
@@ -9,7 +9,9 @@
 #ifndef _MAIN_H_
 #define _MAIN_H_
 
+#define MLTON_GC_INTERNAL
 #include "platform.h"
+#undef MLTON_GC_INTERNAL
 
 /* The label must be declared as weak because gcc's optimizer may prove that
  * the code that declares the label is dead and hence eliminate the declaration.
@@ -25,8 +27,8 @@
 #define Vector(a, b, c, d) { a, b, c, d },
 #define EndVectors };
 
-#define LoadArray(a, f) sfread (a, sizeof(*a), cardof(a), f)
-#define SaveArray(a, fd) swrite (fd, a, sizeof(*a) * cardof(a))
+#define LoadArray(a, fd) read_safe (fd, a, sizeof(*a) * cardof(a))
+#define SaveArray(a, fd) write_safe (fd, a, sizeof(*a) * cardof(a))
 
 Pointer gcStateAddress;
 
@@ -34,35 +36,35 @@
         gcStateAddress = &gcState;                                      \
         gcState.alignment = al;                                         \
         gcState.atMLtons = atMLtons;                                    \
-        gcState.atMLtonsSize = cardof(atMLtons);                        \
+        gcState.atMLtonsLength = cardof(atMLtons);                      \
         gcState.frameLayouts = frameLayouts;                            \
-        gcState.frameLayoutsSize = cardof(frameLayouts);                \
-        gcState.frameSources = frameSources;                            \
-        gcState.frameSourcesSize = cardof(frameSources);                \
+        gcState.frameLayoutsLength = cardof(frameLayouts);              \
         gcState.globals = globalPointer;                                \
-        gcState.globalsSize = cardof(globalPointer);                    \
+        gcState.globalsLength = cardof(globalPointer);                  \
         gcState.intInfInits = intInfInits;                              \
-        gcState.intInfInitsSize = cardof(intInfInits);                  \
+        gcState.intInfInitsLength = cardof(intInfInits);                \
         gcState.loadGlobals = loadGlobals;                              \
         gcState.magic = mg;                                             \
         gcState.maxFrameSize = mfs;                                     \
         gcState.mutatorMarksCards = mmc;                                \
         gcState.objectTypes = objectTypes;                              \
-        gcState.objectTypesSize = cardof(objectTypes);                  \
-        gcState.profileKind = pk;                                       \
-        gcState.profileStack = ps;                                      \
+        gcState.objectTypesLength = cardof(objectTypes);                \
         gcState.returnAddressToFrameIndex = returnAddressToFrameIndex;  \
         gcState.saveGlobals = saveGlobals;                              \
-        gcState.sourceLabels = sourceLabels;                            \
-        gcState.sourceLabelsSize = cardof(sourceLabels);                \
-        gcState.sourceNames = sourceNames;                              \
-        gcState.sourceNamesSize = cardof(sourceNames);                  \
-        gcState.sourceSeqs = sourceSeqs;                                \
-        gcState.sourceSeqsSize = cardof(sourceSeqs);                    \
-        gcState.sources = sources;                                      \
-        gcState.sourcesSize = cardof(sources);                          \
         gcState.vectorInits = vectorInits;                              \
-        gcState.vectorInitsSize = cardof(vectorInits);                  \
+        gcState.vectorInitsLength = cardof(vectorInits);                \
+        gcState.sourceMaps.frameSources = frameSources;                 \
+        gcState.sourceMaps.frameSourcesLength = cardof(frameSources);   \
+        gcState.sourceMaps.sourceLabels = sourceLabels;                 \
+        gcState.sourceMaps.sourceLabelsLength = cardof(sourceLabels);   \
+        gcState.sourceMaps.sourceNames = sourceNames;                   \
+        gcState.sourceMaps.sourceNamesLength = cardof(sourceNames);     \
+        gcState.sourceMaps.sourceSeqs = sourceSeqs;                     \
+        gcState.sourceMaps.sourceSeqsLength = cardof(sourceSeqs);       \
+        gcState.sourceMaps.sources = sources;                           \
+        gcState.sourceMaps.sourcesLength = cardof(sources);             \
+        gcState.profiling.kind = pk;                                    \
+        gcState.profiling.stack = ps;                                   \
         MLton_init (argc, argv, &gcState);                              \
 
 void MLton_callFromC ();

Modified: mlton/branches/on-20050822-x86_64-branch/include/x86-main.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/include/x86-main.h	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/include/x86-main.h	2005-11-08 02:59:15 UTC (rev 4171)
@@ -93,13 +93,13 @@
                 fprintf (stderr, "MLton_callFromC() starting\n");       \
         s = &gcState;                                                   \
         s->savedThread = s->currentThread;                              \
-        s->canHandle += 3;                                              \
+        s->atomicState += 3;                                            \
         /* Return to the C Handler thread. */                           \
-        GC_switchToThread (s, s->callFromCHandler, 0);                  \
-        jump = *(pointer*)(s->stackTop - WORD_SIZE);                    \
+        GC_switchToThread (s, s->callFromCHandlerThread, 0);            \
+        jump = *(pointer*)(s->stackTop - GC_RETURNADDRESS_SIZE);        \
         MLton_jumpToSML(jump);                                          \
         GC_switchToThread (s, s->savedThread, 0);                       \
-        s->savedThread = BOGUS_THREAD;                                  \
+        s->savedThread = BOGUS_OBJPTR;                                  \
         if (DEBUG_X86CODEGEN)                                           \
                 fprintf (stderr, "MLton_callFromC() done\n");           \
         return;                                                         \
@@ -109,11 +109,11 @@
         extern pointer ml;                                              \
                                                                         \
         Initialize (al, mg, mfs, mmc, pk, ps);                          \
-        if (gcState.isOriginal) {                                       \
+        if (gcState.amOriginal) {                                       \
                 real_Init();                                            \
                 jump = (pointer)&ml;                                    \
         } else {                                                        \
-                jump = *(pointer*)(gcState.stackTop - WORD_SIZE);       \
+                jump = *(pointer*)(gcState.stackTop - GC_RETURNADDRESS_SIZE); \
         }                                                               \
         MLton_jumpToSML(jump);                                          \
         return 1;                                                       \

Modified: mlton/branches/on-20050822-x86_64-branch/mlton/backend/ssa-to-rssa.fun
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/mlton/backend/ssa-to-rssa.fun	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/mlton/backend/ssa-to-rssa.fun	2005-11-08 02:59:15 UTC (rev 4171)
@@ -163,25 +163,41 @@
             target = Direct "Thread_switchTo",
             writesStackTop = true}
 
-      fun weakCanGet t =
-         vanilla {args = Vector.new1 t,
-                  name = "GC_weakCanGet",
-                  prototype = let
-                                 open CType
-                              in
-                                 (Vector.new1 Pointer, SOME bool)
-                              end,
-                  return = Type.bool}
+      fun weakCanGet {arg} =
+         T {args = Vector.new2 (gcState, arg),
+            bytesNeeded = NONE,
+            convention = Cdecl,
+            ensuresBytesFree = false,
+            mayGC = false,
+            maySwitchThreads = false,
+            modifiesFrontier = false,
+            prototype = let
+                           open CType
+                        in
+                           (Vector.new2 (Pointer, Pointer), SOME bool)
+                        end,
+            readsStackTop = false,
+            return = Type.bool,
+            target = Direct "GC_weakCanGet",
+            writesStackTop = false}
          
       fun weakGet {arg, return} =
-         vanilla {args = Vector.new1 arg,
-                  name = "GC_weakGet",
-                  prototype = let
-                                 open CType
-                              in
-                                 (Vector.new1 Pointer, SOME Pointer)
-                              end,
-                  return = return}
+         T {args = Vector.new2 (gcState, arg),
+            bytesNeeded = NONE,
+            convention = Cdecl,
+            ensuresBytesFree = false,
+            mayGC = false,
+            maySwitchThreads = false,
+            modifiesFrontier = false,
+            prototype = let
+                           open CType
+                        in
+                           (Vector.new2 (Pointer, Pointer), SOME Pointer)
+                        end,
+            readsStackTop = false,
+            return = return,
+            target = Direct "GC_weakGet",
+            writesStackTop = false}
                   
       fun weakNew {arg, return} =
          T {args = Vector.new3 (gcState, Word32, arg),
@@ -1330,16 +1346,33 @@
                                | Weak_canGet =>
                                     ifIsWeakPointer
                                     (varType (arg 0),
-                                     fn _ => simpleCCall (CFunction.weakCanGet
-                                                          (Operand.ty (a 0))),
+                                     fn _ => 
+                                     let
+                                        val func = 
+                                           CFunction.weakCanGet
+                                           {arg = Operand.ty (a 0)}
+                                     in
+                                        ccall {args = (Vector.concat
+                                                       [Vector.new1 GCState,
+                                                        vos args]),
+                                               func = func}
+                                     end,
                                      fn () => move (Operand.bool false))
                                | Weak_get =>
                                     ifIsWeakPointer
                                     (varType (arg 0),
-                                     fn t => (simpleCCall
-                                              (CFunction.weakGet
-                                               {arg = Operand.ty (a 0),
-                                                return = t})),
+                                     fn t => 
+                                     let
+                                        val func = 
+                                           CFunction.weakGet
+                                           {arg = Operand.ty (a 0),
+                                            return = t}
+                                     in
+                                        ccall {args = (Vector.concat
+                                                       [Vector.new1 GCState,
+                                                        vos args]),
+                                               func = func}
+                                     end,
                                      none)
                                | Weak_new =>
                                     ifIsWeakPointer

Modified: mlton/branches/on-20050822-x86_64-branch/mlton/codegen/c-codegen/c-codegen.fun
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/mlton/codegen/c-codegen/c-codegen.fun	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/mlton/codegen/c-codegen/c-codegen.fun	2005-11-08 02:59:15 UTC (rev 4171)
@@ -253,11 +253,11 @@
                                    CType.toString t, ", fd);\n"])))
                 ; print "}\n")
             val _ =
-               (print "static void loadGlobals (FILE *file) {\n"
+               (print "static void loadGlobals (int fd) {\n"
                 ; (List.foreach
                    (CType.all, fn t =>
                     print (concat ["\tLoadArray (global",
-                                   CType.toString t, ", file);\n"])))
+                                   CType.toString t, ", fd);\n"])))
                 ; print "}\n")
          in
             ()
@@ -296,7 +296,7 @@
       fun declareFrameOffsets () =
          Vector.foreachi
          (frameOffsets, fn (i, v) =>
-          (print (concat ["static ushort frameOffsets", C.int i, "[] = {"])
+          (print (concat ["static uint16_t frameOffsets", C.int i, "[] = {"])
            ; print (C.int (Vector.length v))
            ; Vector.foreach (v, fn i => (print ","; print (C.bytes i)))
            ; print "};\n"))
@@ -309,18 +309,18 @@
                              print (concat ["\t", toString (i, x), ",\n"]))
           ; print "};\n")
       fun declareFrameLayouts () =
-         declareArray ("GC_frameLayout", "frameLayouts", frameLayouts,
+         declareArray ("struct GC_frameLayout", "frameLayouts", frameLayouts,
                        fn (_, {frameOffsetsIndex, isC, size}) =>
                        concat ["{",
                                C.bool isC,
+                               ", frameOffsets", C.int frameOffsetsIndex,
                                ", ", C.bytes size,
-                               ", frameOffsets", C.int frameOffsetsIndex,
                                "}"])
       fun declareAtMLtons () =
-         declareArray ("string", "atMLtons", !Control.atMLtons, C.string o #2)
+         declareArray ("char*", "atMLtons", !Control.atMLtons, C.string o #2)
       fun declareObjectTypes () =
          declareArray
-         ("GC_ObjectType", "objectTypes", objectTypes,
+         ("struct GC_objectType", "objectTypes", objectTypes,
           fn (_, ty) =>
           let
              datatype z = datatype Runtime.RObjectType.t
@@ -380,22 +380,22 @@
                                 declareProfileLabel (label, print))
                 ; (Vector.foreachi
                    (sourceSeqs, fn (i, v) =>
-                    (print (concat ["static int sourceSeq",
+                    (print (concat ["static uint32_t sourceSeq",
                                     Int.toString i,
                                     "[] = {"])
                      ; print (C.int (Vector.length v))
                      ; Vector.foreach (v, fn i =>
                                        (print (concat [",", C.int i])))
                      ; print "};\n")))
-                ; declareArray ("uint", "*sourceSeqs", sourceSeqs, fn (i, _) =>
+                ; declareArray ("uint32_t*", "sourceSeqs", sourceSeqs, fn (i, _) =>
                                 concat ["sourceSeq", Int.toString i])
-                ; declareArray ("uint", "frameSources", frameSources, C.int o #2)
+                ; declareArray ("GC_sourceSeqIndex", "frameSources", frameSources, C.int o #2)
                 ; (declareArray
                    ("struct GC_sourceLabel", "sourceLabels", labels,
                     fn (_, {label, sourceSeqsIndex}) =>
                     concat ["{(pointer)&", ProfileLabel.toString label, ", ",
                             C.int sourceSeqsIndex, "}"]))
-                ; declareArray ("string", "sourceNames", names, C.string o #2)
+                ; declareArray ("char*", "sourceNames", names, C.string o #2)
                 ; declareArray ("struct GC_source", "sources", sources,
                                 fn (_, {nameIndex, successorsIndex}) =>
                                 concat ["{ ", Int.toString nameIndex, ", ",

Modified: mlton/branches/on-20050822-x86_64-branch/mlton/main/compile.fun
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/mlton/main/compile.fun	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/mlton/main/compile.fun	2005-11-08 02:59:15 UTC (rev 4171)
@@ -451,15 +451,15 @@
          in
             Runtime.GCField.setOffsets
             {
-             canHandle = get "canHandle",
-             cardMap = get "cardMapForMutator",
+             canHandle = get "atomicState",
+             cardMap = get "generationalMaps.cardMapAbsolute",
              currentThread = get "currentThread",
              exnStack = get "exnStack",
              frontier = get "frontier",
              limit = get "limit",
              limitPlusSlop = get "limitPlusSlop",
              maxFrameSize = get "maxFrameSize",
-             signalIsPending = get "signalIsPending",
+             signalIsPending = get "signalsInfo.signalIsPending",
              stackBottom = get "stackBottom",
              stackLimit = get "stackLimit",
              stackTop = get "stackTop"

Modified: mlton/branches/on-20050822-x86_64-branch/mlton/main/lookup-constant.fun
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/mlton/main/lookup-constant.fun	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/mlton/main/lookup-constant.fun	2005-11-08 02:59:15 UTC (rev 4171)
@@ -42,15 +42,15 @@
 
 val gcFields =
    [
-    "canHandle",
+    "atomicState",
     "currentThread",
     "exnStack",
     "frontier",
-    "cardMapForMutator",
+    "generationalMaps.cardMapAbsolute",
     "limit",
     "limitPlusSlop",
     "maxFrameSize",
-    "signalIsPending",
+    "signalsInfo.signalIsPending",
     "stackBottom",
     "stackLimit",
     "stackTop"
@@ -73,7 +73,8 @@
    in
       List.foreach
       (List.concat
-       [["#include \"platform.h\"",
+       [["#define MLTON_GC_INTERNAL",
+         "#include \"platform.h\"",
          "struct GC_state gcState;",
          "",
          "int main (int argc, char **argv) {"],

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/Makefile
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/Makefile	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/Makefile	2005-11-08 02:59:15 UTC (rev 4171)
@@ -68,18 +68,29 @@
 #	-Winline -Wdisabled-optimization
 DEBUGWARNFLAGS = $(DEBUGFLAGS) $(WARNFLAGS) -Wunused
 
+UTILCFILES =							\
+	$(shell find util -type f | grep '\.c$$')
+UTILHFILES =							\
+	$(shell find util -type f | grep '\.h$$')
+UTILOFILES = $(foreach f, $(UTILCFILES), $(basename $(f)).o)
+
+GCCFILES =							\
+	$(shell find gc -type f | grep '\.c$$')
+GCHFILES =							\
+	$(shell find gc -type f | grep '\.h$$')
+
 CFILES = 							\
-	$(shell find util -type f | grep '\.c$$')		\
+	$(UTILCFILES)						\
 	$(shell find basis -type f | grep '\.c$$' | grep -v Real/)	\
 	$(shell find Posix -type f | grep '\.c$$')		\
 	gc.c							\
 	platform.c
 
 HFILES = 							\
+	$(UTILHFILES)						\
 	util.h							\
-	$(shell find util -type f | grep '\.h$$')		\
+	$(GCHFILES)						\
 	gc.h							\
-	$(shell find gc -type f | grep '\.h$$')			\
 	types.h							\
 	platform.h						\
 	platform/$(TARGET_OS).h
@@ -143,18 +154,26 @@
 runtime.c: $(CFILES)
 	cat $(CFILES) >runtime.c
 
-gc.o: gc.c $(shell find gc -type f | grep '\.c$$') $(HFILES) 
-	$(CC) $(CFLAGS) $(WARNFLAGS) -c -o $@ $<
 
-gc-gdb.o: gc.c $(shell find gc -type f | grep '\.c$$') $(HFILES) 
+util/%-gdb.o: util/%.c util.h $(UTILHFILES)
 	$(CC) $(DEBUGFLAGS) $(DEBUGWARNFLAGS) -O1 -DASSERT=1 -c -o $@ $<
 
-util/%.o: util/%.c $(HFILES)
+util/%.o: util/%.c util.h $(UTILHFILES)
 	$(CC) $(CFLAGS) $(WARNFLAGS) -c -o $@ $<
 
-util/%-gdb.o: util/%.c $(HFILES)
+types.h: gen/gen-types.c util.h $(UTILOFILES)
+	rm -f types.h
+	$(CC) $(CFLAGS) $(WARNFLAGS) -o gen-types gen/gen-types.c $(UTILOFILES)
+	./gen-types
+	chmod a+r types.h
+	rm -f gen-types
+
+gc-gdb.o: gc.c $(GCCFILES) $(HFILES) 
 	$(CC) $(DEBUGFLAGS) $(DEBUGWARNFLAGS) -O1 -DASSERT=1 -c -o $@ $<
 
+gc.o: gc.c $(GCCFILES) $(HFILES) 
+	$(CC) $(CFLAGS) $(WARNFLAGS) -c -o $@ $<
+
 # It looks like we don't follow the C spec w.r.t. aliasing.  And gcc
 # -O2 catches us on the code in Real/*.c where we treat a double as a
 # chunk of two words.  Files that have been known to cause problems
@@ -162,9 +181,9 @@
 # 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) $(DEBUGFLAGS) -O1 -DASSERT=1 -c -o $@ $<
+	$(CC) $(DEBUGFLAGS) $(WARNFLAGS) -O1 -DASSERT=1 -c -o $@ $<
 basis/Real/%.o: basis/Real/%.c gdtoa/arith.h
-	$(CC) $(CFLAGS) -O1 -fno-strict-aliasing -c -o $@ $<
+	$(CC) $(CFLAGS) $(DEBUGWARNFLAGS) -O1 -fno-strict-aliasing -c -o $@ $<
 
 %-gdb.o: %.c $(HFILES)
 	$(CC) $(DEBUGFLAGS) -O1 -DASSERT=1 -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-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/Posix/Error.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -8,6 +8,6 @@
         return errno;
 }
 
-Cstring Posix_Error_strerror (Syserror n) {
+Cstring Posix_Error_strerror (Int n) {
         return (Cstring)(strerror (n));
 }

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/Stat.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/Stat.c	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/Stat.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -50,10 +50,10 @@
         return fstat (f, &statbuf);
 }
 
-Int Posix_FileSys_Stat_lstat (NullString f) {
+Int Posix_FileSys_Stat_lstat (Pointer f) {
         return lstat ((char*)f, &statbuf);
 }
 
-Int Posix_FileSys_Stat_stat (NullString f) {    
+Int Posix_FileSys_Stat_stat (Pointer f) {    
         return stat ((char*)f, &statbuf);
 }

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/Utimbuf.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/Utimbuf.c	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/Utimbuf.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -10,6 +10,6 @@
         utimbuf.modtime = i;
 } 
 
-Int Posix_FileSys_Utimbuf_utime (NullString s) {
+Int Posix_FileSys_Utimbuf_utime (Pointer s) {
         return (Int)utime((char *)s, &utimbuf);
 }

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/access.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/access.c	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/access.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -1,5 +1,5 @@
 #include "platform.h"
 
-Int Posix_FileSys_access (NullString f, Word w) {
+Int Posix_FileSys_access (Pointer f, Word w) {
         return access ((char *) f, w);
 }

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/chdir.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/chdir.c	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/chdir.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -1,5 +1,5 @@
 #include "platform.h"
 
-Int Posix_FileSys_chdir(Cpointer p) {
+Int Posix_FileSys_chdir(Pointer p) {
         return chdir((char *) p);
 }

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/chmod.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/chmod.c	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/chmod.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -1,5 +1,5 @@
 #include "platform.h"
 
-Int Posix_FileSys_chmod (NullString p, Mode m) {
+Int Posix_FileSys_chmod (Pointer p, Mode m) {
         return chmod ((char *) p, m);
 }

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/chown.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/chown.c	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/chown.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -1,5 +1,5 @@
 #include "platform.h"
 
-Int Posix_FileSys_chown (NullString p, Uid u, Gid g) {
+Int Posix_FileSys_chown (Pointer p, Uid u, Gid g) {
         return chown ((char *) p, u, g);
 }

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/link.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/link.c	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/link.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -1,5 +1,5 @@
 #include "platform.h"
 
-Int Posix_FileSys_link (NullString p1, NullString p2) {
+Int Posix_FileSys_link (Pointer p1, Pointer p2) {
         return link ((char *) p1, (char *) p2);
 }

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/mkdir.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/mkdir.c	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/mkdir.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -1,5 +1,5 @@
 #include "platform.h"
 
-Int Posix_FileSys_mkdir (NullString p, Word w) {
+Int Posix_FileSys_mkdir (Pointer p, Word w) {
         return mkdir2 ((char *) p, w);
 }

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/mkfifo.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/mkfifo.c	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/mkfifo.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -1,5 +1,5 @@
 #include "platform.h"
 
-Int Posix_FileSys_mkfifo (NullString p, Word w) {
+Int Posix_FileSys_mkfifo (Pointer p, Word w) {
         return mkfifo ((char *) p, w);
 }

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/open.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/open.c	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/open.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -4,7 +4,7 @@
 #define DEBUG FALSE
 #endif
 
-Int Posix_FileSys_open (NullString p, Word w, Mode m) {
+Int Posix_FileSys_open (Pointer p, Word w, Mode m) {
         Int res;
 
         res = open ((char *) p, w, m);

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/pathconf.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/pathconf.c	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/pathconf.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -1,5 +1,5 @@
 #include "platform.h"
 
-Int Posix_FileSys_pathconf (NullString p, Int n) {
+Int Posix_FileSys_pathconf (Pointer p, Int n) {
         return pathconf ((char *)p, n);
 }

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/readlink.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/readlink.c	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/readlink.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -1,5 +1,5 @@
 #include "platform.h"
 
-Int Posix_FileSys_readlink (NullString p, Pointer b, Int n) {
+Int Posix_FileSys_readlink (Pointer p, Pointer b, Int n) {
         return readlink ((char*)p, (char*)b, n);
 }

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/rename.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/rename.c	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/rename.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -1,5 +1,5 @@
 #include "platform.h"
 
-Int Posix_FileSys_rename (NullString p1, NullString p2) {
+Int Posix_FileSys_rename (Pointer p1, Pointer p2) {
         return rename ((char *) p1, (char *) p2);
 }

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/rmdir.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/rmdir.c	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/rmdir.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -1,5 +1,5 @@
 #include "platform.h"
 
-Int Posix_FileSys_rmdir (NullString p) {
+Int Posix_FileSys_rmdir (Pointer p) {
         return rmdir ((char *) p);
 }

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/symlink.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/symlink.c	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/symlink.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -1,5 +1,5 @@
 #include "platform.h"
 
-Int Posix_FileSys_symlink (NullString p1, NullString p2) {
+Int Posix_FileSys_symlink (Pointer p1, Pointer p2) {
         return symlink ((char *) p1, (char *) p2);
 }

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/unlink.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/unlink.c	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/unlink.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -1,5 +1,5 @@
 #include "platform.h"
 
-Word Posix_FileSys_unlink (NullString p) {
+Word Posix_FileSys_unlink (Pointer p) {
         return unlink ((char *) p);
 }

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-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/Posix/ProcEnv/getenv.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -1,5 +1,5 @@
 #include "platform.h"
 
-Cstring Posix_ProcEnv_getenv(NullString s) {
+Cstring Posix_ProcEnv_getenv(Pointer s) {
         return (Cstring)getenv((char *)s);
 }

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/Posix/ProcEnv/setenv.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/Posix/ProcEnv/setenv.c	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/Posix/ProcEnv/setenv.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -1,5 +1,5 @@
 #include "platform.h"
 
-Int Posix_ProcEnv_setenv (NullString s, NullString v) {
-        return setenv ((char *)s, (char *)v, 1);
+Int Posix_ProcEnv_setenv (Pointer s, Pointer v) {
+        return setenv ((char*)s, (char*)v, 1);
 }

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-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/Posix/ProcEnv/setgroups.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -8,7 +8,7 @@
 
         size = GC_getArrayLength (groups);
         list = (gid_t*)(calloc_safe (size, sizeof(*list)));
-        assert (size <= (sizeof(list) / sizeof(*list)));
+        assert (size <= cardof(list));
         for (i = 0; i < size; ++i)
                 list[i] = ((Word*)groups)[i];
         res = setgroups (size, list);

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/Posix/Process/exece.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/Posix/Process/exece.c	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/Posix/Process/exece.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -1,6 +1,6 @@
 #include "platform.h"
 
-Int Posix_Process_exece (NullString p, Pointer a, Pointer e) {
+Int Posix_Process_exece (Pointer p, Pointer a, Pointer e) {
         char            *path;
         char            *asaved;
         char            *esaved;

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/Posix/Process/execp.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/Posix/Process/execp.c	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/Posix/Process/execp.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -1,6 +1,6 @@
 #include "platform.h"
 
-Int Posix_Process_execp (NullString f, Pointer a) {
+Int Posix_Process_execp (Pointer f, Pointer a) {
         char            *file;
         char            *saved;
         char            **args;

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/Posix/SysDB/Group.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/Posix/SysDB/Group.c	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/Posix/SysDB/Group.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -18,6 +18,6 @@
         return NULL != (group = getgrgid ((gid_t)g));
 }
 
-Bool Posix_SysDB_getgrnam(NullString s) {
+Bool Posix_SysDB_getgrnam(Pointer s) {
         return NULL != (group = getgrnam ((char*)s));
 }

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/basis/Date.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/basis/Date.c	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/Date.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -103,6 +103,6 @@
         return mktime(&tm);
 }
 
-Int Date_strfTime(Pointer buf, Int n, NullString fmt) {
+Int Date_strfTime(Pointer buf, Int n, Pointer fmt) {
         return strftime((char*)(buf), n, (char*)(fmt), &tm);
 }

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-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/IntInf.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -8,6 +8,7 @@
 
 #define MLTON_GC_INTERNAL
 #include "platform.h"
+#undef MLTON_GC_INTERNAL
 
 enum {
   DEBUG_INT_INF = FALSE,

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-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/MLton/spawne.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -28,7 +28,7 @@
         return result;
 }
 #else
-Int MLton_Process_spawne (NullString p, Pointer a, Pointer e) {
+Int MLton_Process_spawne (Pointer p, Pointer a, 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-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/MLton/spawnp.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -18,7 +18,7 @@
         return result;
 }
 #else
-Int MLton_Process_spawnp (NullString p, Pointer a) {
+Int MLton_Process_spawnp (Pointer p, Pointer a) {
         die ("MLton_Process_spawnp not implemented");
 }
 #endif

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/basis/MLton/thread.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/basis/MLton/thread.c	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/MLton/thread.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -6,49 +6,49 @@
         DEBUG_THREAD = FALSE,
 };
 
-Thread Thread_current () {
-        Thread t;
+Pointer Thread_current () {
+        Pointer t;
 
-        t = (Thread)(GC_getCurrentThread (&gcState));
+        t = (Pointer)(GC_getCurrentThread (&gcState));
         if (DEBUG_THREAD)
                 fprintf (stderr, "0x%08x = Thread_current ()\n", (uint)t);
         return t;
 }
 
-void Thread_finishHandler () {
-        GC_finishHandler (&gcState);
+void Thread_finishSignalHandler () {
+        GC_finishSignalHandler (&gcState);
 }
 
-Thread Thread_saved () {
-        Thread t;
+Pointer Thread_saved () {
+        Pointer t;
 
-        t = (Thread)(GC_getSavedThread (&gcState));
+        t = (Pointer)(GC_getSavedThread (&gcState));
         if (DEBUG_THREAD)
                 fprintf (stderr, "0x%08x = Thread_saved ()\n", (uint)t);
         return t;
 }
 
-void Thread_setCallFromCHandler (Thread t) {
+void Thread_setCallFromCHandler (Pointer t) {
         GC_setCallFromCHandlerThread (&gcState, (GC_thread)t);
 }
 
-void Thread_setSaved (Thread t) {
+void Thread_setSaved (Pointer t) {
         if (DEBUG_THREAD)
                 fprintf (stderr, "Thread_setSaved (0x%08x)\n", (uint)t);
         GC_setSavedThread (&gcState, (GC_thread)t);
 }
 
-void Thread_setSignalHandler (Thread t) {
+void Thread_setSignalHandler (Pointer t) {
         GC_setSignalHandlerThread (&gcState, (GC_thread)t);
 }
 
-void Thread_startHandler () {
-        GC_startHandler (&gcState);
+void Thread_startSignalHandler () {
+        GC_startSignalHandler (&gcState);
 }
 
-void Thread_switchTo (Thread thread, Word ensureBytesFree) {
+void Thread_switchTo (Pointer t, Word ensureBytesFree) {
         if (DEBUG_THREAD)
                 fprintf (stderr, "Thread_switchTo (0x%08x, %u)\n",
-                                (uint)thread, (uint)ensureBytesFree);
-        GC_switchToThread (&gcState, (GC_thread)thread, ensureBytesFree);
+                                (uint)t, (uint)ensureBytesFree);
+        GC_switchToThread (&gcState, (GC_thread)t, ensureBytesFree);
 }

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-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/Math.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -1,7 +1,6 @@
 #include "platform.h"
 
 #define unaryReal(f, g)                                         \
-        Real64 g (Real64 x);                                    \
         Real64 Real64_##f (Real64 x) {          \
                 return g (x);                                   \
         }                                                       \
@@ -13,7 +12,6 @@
 #undef unaryReal
 
 #define binaryReal(f, g)                                                        \
-        Real64 g (Real64 x, Real64 y);                                          \
         Real64 Real64_Math_##f (Real64 x, Real64 y) {           \
                 return g (x, y);                                                \
         }                                                                       \
@@ -24,7 +22,6 @@
 #undef binaryReal
 
 #define unaryReal(f, g)                                         \
-        Real64 g (Real64 x);                                    \
         Real64 Real64_Math_##f (Real64 x) {     \
                 return g (x);                                   \
         }                                                       \
@@ -43,7 +40,6 @@
 unaryReal(tan, tan)
 #undef unaryReal
 
-double ldexp (double x, int i);
 Real64 Real64_ldexp (Real64 x, Int32 i) {
         return ldexp (x, i);
 }

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/frexp.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/frexp.c	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/frexp.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -1,7 +1,5 @@
 #include "platform.h"
 
-double frexp (double x, int* exp);
-
 Real64 Real64_frexp (Real64 x, Int *exp) {
         int exp_;
         Real64 res;

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/cenv.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/cenv.h	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/cenv.h	2005-11-08 02:59:15 UTC (rev 4171)
@@ -38,6 +38,7 @@
 
 #include <dirent.h>
 #include <signal.h>
+#include <termios.h>
 #include <time.h>
 #include <utime.h>
 #include <sys/resource.h>

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/TODO
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/TODO	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/TODO	2005-11-08 02:59:15 UTC (rev 4171)
@@ -20,4 +20,3 @@
         be unnecessary.
 * Why do {load,save}Globals differ in the representation of the file?
 * Why does hash-table use malloc/free while generational maps use mmap/munmap?
-* The succssor field of GC_source appears to be unused.
\ No newline at end of file

Copied: mlton/branches/on-20050822-x86_64-branch/runtime/gc/align.h (from rev 4168, mlton/branches/on-20050822-x86_64-branch/runtime/gc/align.c)
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/align.c	2005-11-07 02:39:08 UTC (rev 4168)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/align.h	2005-11-08 02:59:15 UTC (rev 4171)
@@ -0,0 +1,10 @@
+/* Copyright (C) 1999-2005 Henry Cejtin, Matthew Fluet, Suresh
+ *    Jagannathan, and Stephen Weeks.
+ * Copyright (C) 1997-2000 NEC Research Institute.
+ *
+ * MLton is released under a BSD-style license.
+ * See the file MLton-LICENSE for details.
+ */
+
+bool isFrontierAligned (GC_state s, pointer p);
+pointer alignFrontier (GC_state s, pointer p);

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/cheney-copy.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/cheney-copy.c	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/cheney-copy.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -29,7 +29,7 @@
     } else {
       if (DEBUG_WEAK)
         fprintf (stderr, "cleared\n");
-      *(getHeaderp(p)) = GC_WEAK_GONE_HEADER;
+      *(getHeaderp((pointer)w)) = GC_WEAK_GONE_HEADER;
       w->objptr = BOGUS_OBJPTR;
     }
   }

Deleted: mlton/branches/on-20050822-x86_64-branch/runtime/gc/debug.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/debug.c	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/debug.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -1,34 +0,0 @@
-/* Copyright (C) 1999-2005 Henry Cejtin, Matthew Fluet, Suresh
- *    Jagannathan, and Stephen Weeks.
- * Copyright (C) 1997-2000 NEC Research Institute.
- *
- * MLton is released under a BSD-style license.
- * See the file MLton-LICENSE for details.
- */
-
-#ifndef DEBUG
-#define DEBUG FALSE
-#endif
-
-enum {
-  DEBUG_ARRAY = FALSE,
-  DEBUG_CALL_STACK = FALSE,
-  DEBUG_CARD_MARKING = FALSE,
-  DEBUG_DETAILED = FALSE,
-  DEBUG_ENTER_LEAVE = FALSE,
-  DEBUG_GENERATIONAL = FALSE,
-  DEBUG_MARK_COMPACT = FALSE,
-  DEBUG_MEM = FALSE,
-  DEBUG_PROFILE = FALSE,
-  DEBUG_RESIZING = FALSE,
-  DEBUG_SHARE = FALSE,
-  DEBUG_SIGNALS = FALSE,
-  DEBUG_SIZE = FALSE,
-  DEBUG_SOURCES = FALSE,
-  DEBUG_STACKS = FALSE,
-  DEBUG_THREADS = FALSE,
-  DEBUG_WEAK = FALSE,
-  DEBUG_WORLD = FALSE,
-  FORCE_GENERATIONAL = FALSE,
-  FORCE_MARK_COMPACT = FALSE,
-};

Copied: mlton/branches/on-20050822-x86_64-branch/runtime/gc/debug.h (from rev 4168, mlton/branches/on-20050822-x86_64-branch/runtime/gc/debug.c)

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/exports.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/exports.h	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/exports.h	2005-11-08 02:59:15 UTC (rev 4171)
@@ -17,8 +17,8 @@
 
 size_t GC_size (GC_state s, pointer root);
 
-void GC_startHandler (GC_state s);
-void GC_finishHandler (GC_state s);
+void GC_startSignalHandler (GC_state s);
+void GC_finishSignalHandler (GC_state s);
 
 void GC_switchToThread (GC_state s, GC_thread t, size_t ensureBytesFree);
 
@@ -32,5 +32,10 @@
 
 void GC_profileDone (GC_state s);
 
+void GC_handleSigProf (pointer pc);
+
+
+void GC_saveWorld (GC_state s, int fd);
+
+int GC_init (GC_state s, int argc, char **argv);
 void GC_done (GC_state s);
-

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/foreach.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/foreach.c	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/foreach.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -68,8 +68,9 @@
     }
   } else if (WEAK_TAG == tag) {
     p += sizeofNumNonObjptrs (NORMAL_TAG, numNonObjptrs);
-    if (not skipWeaks and 1 == numObjptrs) {
-      callIfIsObjptr (s, f, (objptr*)p);
+    if (1 == numObjptrs) {
+      if (not skipWeaks)
+        callIfIsObjptr (s, f, (objptr*)p);
       p += OBJPTR_SIZE;
     }
   } else if (ARRAY_TAG == tag) {

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/forward.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/forward.c	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/forward.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -127,15 +127,19 @@
       }
     }
     /* Store the forwarding pointer in the old object. */
-    *(GC_header*)(p - GC_HEADER_SIZE) = GC_FORWARDED;
-    *(objptr*)p = pointerToObjptr(s->forwardState.back + headerBytes, 
-                                  s->forwardState.toStart);
+    *((GC_header*)(p - GC_HEADER_SIZE)) = GC_FORWARDED;
+    *((objptr*)p) = pointerToObjptr (s->forwardState.back + headerBytes, 
+                                     s->forwardState.toStart);
     /* Update the back of the queue. */
     s->forwardState.back += size + skip;
     assert (isAligned ((size_t)s->forwardState.back + GC_NORMAL_HEADER_SIZE, 
                        s->alignment));
   }
-  *opp = *(objptr*)p;
+  *opp = *((objptr*)p);
+  if (DEBUG_DETAILED)
+    fprintf (stderr,
+             "forwardObjptr --> *opp = "FMTPTR"\n",
+             (uintptr_t)*opp);
   assert (isObjptrInToSpace (s, *opp));
 }
 

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/garbage-collection.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/garbage-collection.c	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/garbage-collection.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -187,7 +187,7 @@
   if (0 == bytesRequested)
     bytesRequested = GC_HEAP_LIMIT_SLOP;
   getThreadCurrent(s)->bytesNeeded = bytesRequested;
-  switchToHandlerThreadIfNonAtomicAndSignalPending (s);
+  switchToSignalHandlerThreadIfNonAtomicAndSignalPending (s);
   ensureInvariantForMutator (s, force);
   assert (invariantForMutatorFrontier(s));
   assert (invariantForMutatorStack(s));

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/generational.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/generational.c	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/generational.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -71,7 +71,8 @@
    * in the right place.
    */
   s->generationalMaps.cardMapAbsolute = 
-    pointerToCardMapAddr (s, s->heap.start);
+    s->generationalMaps.cardMap
+    - pointerToCardMapIndexAbsolute (s->heap.start);
   if (DEBUG_CARD_MARKING)
     fprintf (stderr, "setCardMapAbsolute = "FMTPTR"\n",
              (uintptr_t)s->generationalMaps.cardMapAbsolute);
@@ -165,7 +166,7 @@
                     oldCrossMapSize));
     if (DEBUG_MEM)
       fprintf (stderr, "Releasing card/cross map.\n");
-    GC_munmap (oldCardMap, oldCardMapSize + oldCrossMapSize);
+    GC_release (oldCardMap, oldCardMapSize + oldCrossMapSize);
   }
 }
 
@@ -176,7 +177,7 @@
  * entire old generation.  It is useful to check that the incremental
  * update is working correctly.
  */
-bool isCrossMapOK (GC_state s) {
+bool isCrossMapOk (GC_state s) {
   static GC_crossMapElem *map;
   size_t mapSize;
 
@@ -203,7 +204,7 @@
   }
   for (size_t i = 0; i < cardIndex; ++i)
     assert (map[i] == s->generationalMaps.crossMap[i]);
-  GC_munmap (map, mapSize);
+  GC_release (map, mapSize);
   return TRUE;
 }
 

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/handler.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/handler.c	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/handler.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -6,19 +6,19 @@
  * See the file MLton-LICENSE for details.
  */
 
-/* GC_startHandler does not do an enter()/leave(), even though it is
- * exported.  The basis library uses it via _import, not _prim, and so
- * does not treat it as a runtime call -- so the invariant in enter
- * would fail miserably.  It is OK because GC_startHandler must be
- * called from within a critical section.
+/* GC_startSignalHandler does not do an enter()/leave(), even though
+ * it is exported.  The basis library uses it via _import, not _prim,
+ * and so does not treat it as a runtime call -- so the invariant in
+ * enter would fail miserably.  It is OK because GC_startHandler must
+ * be called from within a critical section.
  *
  * Don't make it inline, because it is also called in basis/Thread.c,
  * and when compiling with COMPILE_FAST, they may appear out of order.
  */
-void GC_startHandler (GC_state s) {
+void GC_startSignalHandler (GC_state s) {
   /* Switch to the signal handler thread. */
   if (DEBUG_SIGNALS) {
-    fprintf (stderr, "GC_startHandler\n");
+    fprintf (stderr, "GC_startSignalHandler\n");
   }
   assert (s->atomicState == 1);
   assert (s->signalsInfo.signalIsPending);
@@ -34,17 +34,17 @@
   s->atomicState = 2;
 }
 
-void GC_finishHandler (GC_state s) {
+void GC_finishSignalHandler (GC_state s) {
   if (DEBUG_SIGNALS)
-    fprintf (stderr, "GC_finishHandler ()\n");
+    fprintf (stderr, "GC_finishSignalHandler ()\n");
   assert (s->atomicState == 1);
   s->signalsInfo.amInSignalHandler = FALSE;     
 }
 
-void switchToHandlerThreadIfNonAtomicAndSignalPending (GC_state s) {
+void switchToSignalHandlerThreadIfNonAtomicAndSignalPending (GC_state s) {
   if (s->atomicState == 1 
       and s->signalsInfo.signalIsPending) {
-    GC_startHandler (s);
+    GC_startSignalHandler (s);
     switchToThread (s, s->signalHandlerThread);
   }
 }

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/handler.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/handler.h	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/handler.h	2005-11-08 02:59:15 UTC (rev 4171)
@@ -6,4 +6,4 @@
  * See the file MLton-LICENSE for details.
  */
 
-void switchToHandlerThreadIfNonAtomicAndSignalPending (GC_state s);
+void switchToSignalHandlerThreadIfNonAtomicAndSignalPending (GC_state s);

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/heap.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/heap.c	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/heap.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -340,7 +340,7 @@
     } else {
       unlink_safe (template);
       if (s->controls.messages)
-        showMem ();
+        GC_displayMem ();
       die ("Out of memory.  Unable to allocate %zu bytes.\n",
            /*uintToCommaString*/(minSize));
     }

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/init-world.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/init-world.c	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/init-world.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -51,8 +51,8 @@
 
   assert (isFrontierAligned (s, s->frontier));
   frontier = s->frontier;
-  for (i= 0; i < s->intInfInitsLength; i++) {
-    inits = &s->intInfInits[i];
+  for (i = 0; i < s->intInfInitsLength; i++) {
+    inits = &(s->intInfInits[i]);
     str = inits->mlstr;
     assert (inits->globalIndex < s->globalsLength);
     neg = *str == '~';
@@ -68,7 +68,7 @@
       llen = (slen + 8) / 9;
     assert (slen > 0);
     bp = (GC_intInf)frontier;
-    cp = (unsigned char *)&bp->limbs[llen];
+    cp = (unsigned char *)(&(bp->limbs[llen]));
 
     for (j = 0; j != slen; j++)
       if ('0' <= str[j] && str[j] <= '9')
@@ -163,7 +163,7 @@
     if (DEBUG_DETAILED)
       fprintf (stderr, "allocated vector at "FMTPTR"\n",
                (uintptr_t)(s->globals[inits[i].globalIndex]));
-    GC_memcpy (inits[i].bytes, frontier, dataBytes);
+    memcpy (frontier, inits[i].bytes, dataBytes);
     frontier += objectSize - GC_ARRAY_HEADER_SIZE;
   }
   if (DEBUG_DETAILED)

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/init.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/init.c	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/init.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -68,8 +68,6 @@
 /*                             GC_init                              */
 /* ---------------------------------------------------------------- */
 
-bool MLton_Platform_CygwinUseMmap;
-
 int processAtMLton (GC_state s, int argc, char **argv,
                     char **worldFile) {
   int i;
@@ -200,7 +198,7 @@
             die ("@MLton thread-shrink-ratio argument must be between 0.0 and 1.0");
         } else if (0 == strcmp (arg, "use-mmap")) {
           i++;
-          MLton_Platform_CygwinUseMmap = TRUE;
+          GC_setCygwinUseMmap (TRUE);
         } else if (0 == strcmp (arg, "--")) {
           i++;
           done = TRUE;
@@ -281,9 +279,9 @@
   sigemptyset (&s->signalsInfo.signalsHandled);
   sigemptyset (&s->signalsInfo.signalsPending);
   s->startTime = getCurrentTime ();
-  // s->sysvals.availRam = ;
-  // s->sysvals.totalRam = ;
-  // s->sysvals.pageSize = ;
+  s->sysvals.availRam = GC_availRam ();
+  s->sysvals.totalRam = GC_totalRam ();
+  s->sysvals.pageSize = GC_pageSize ();
   s->weaks = NULL;
 
   initSignalStack (s);
@@ -343,17 +341,3 @@
   s->amInGC = FALSE;
   return res;
 }
-
-/* extern char **environ; /\* for Posix_ProcEnv_environ *\/ */
-
-/* void MLton_init (int argc, char **argv, GC_state s) { */
-/*         int start; */
-
-/*         Posix_ProcEnv_environ = (CstringArray)environ; */
-/*         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_argc = argc - start; */
-/*         CommandLine_argv = (uint)(argv + start); */
-/* } */

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/init.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/init.h	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/init.h	2005-11-08 02:59:15 UTC (rev 4171)
@@ -8,4 +8,3 @@
 
 int processAtMLton (GC_state s, int argc,
                     char **argv, char **worldFile);
-int GC_init (GC_state s, int argc, char **argv);

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/int-inf.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/int-inf.h	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/int-inf.h	2005-11-08 02:59:15 UTC (rev 4171)
@@ -14,7 +14,7 @@
   GC_arrayLength length;
   GC_header header;
   uint32_t isneg;
-  uint32_t *limbs;
+  uint32_t limbs[0];
 } *GC_intInf;
 
 #define GC_INTINF_HEADER GC_WORD32_VECTOR_HEADER

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/new-object.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/new-object.c	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/new-object.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -35,7 +35,7 @@
     s->frontier += bytesRequested;
   }
   GC_profileAllocInc (s, bytesRequested);
-  *(GC_header*)(frontier) = header;
+  *((GC_header*)frontier) = header;
   result = frontier + GC_NORMAL_HEADER_SIZE;
   if (DEBUG)
     fprintf (stderr, FMTPTR " = newObject ("FMTHDR", %zu, %s)\n",

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/object.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/object.c	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/object.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -58,7 +58,7 @@
   assert (1 == (header & GC_VALID_HEADER_MASK)); 
   objectTypeIndex = (header & TYPE_INDEX_MASK) >> TYPE_INDEX_SHIFT; 
   assert (objectTypeIndex < s->objectTypesLength); 
-  objectType = &s->objectTypes [objectTypeIndex]; 
+  objectType = &(s->objectTypes[objectTypeIndex]);
   tag = objectType->tag; 
   hasIdentity = objectType->hasIdentity; 
   numNonObjptrs = objectType->numNonObjptrs; 
@@ -67,11 +67,13 @@
   if (DEBUG_DETAILED) 
     fprintf (stderr, 
              "splitHeader ("FMTHDR")" 
+             "  objectTypeIndex = %u"
              "  tag = %s" 
              "  hasIdentity = %s" 
              "  numNonObjptrs = %"PRIu16 
              "  numObjptrs = %"PRIu16"\n", 
              header, 
+             objectTypeIndex,
              objectTypeTagToString(tag), 
              boolToString(hasIdentity), 
              numNonObjptrs, numObjptrs); 
@@ -104,5 +106,8 @@
     /* Looking at a header word. */
     res = p + GC_NORMAL_HEADER_SIZE;
   assert (isAligned ((uintptr_t)res, s->alignment));
+  if (DEBUG_DETAILED)
+    fprintf (stderr, FMTPTR" = advanceToObjectData ("FMTPTR")\n",
+             (uintptr_t)res, (uintptr_t)p);
   return res;
 }

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/object.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/object.h	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/object.h	2005-11-08 02:59:15 UTC (rev 4171)
@@ -92,7 +92,7 @@
  * numNonObjptrs and numObjptrs fields are interpreted as in a normal
  * object (and, hence, must be (2,1) or (3,0)).
 */
-typedef struct {
+typedef struct GC_objectType {
   /* Keep tag first, at zero offset, since it is referenced most often. */
   GC_objectTypeTag tag;
   bool hasIdentity;
@@ -121,7 +121,5 @@
                   GC_objectTypeTag *tagRet, bool *hasIdentityRet,
                   uint16_t *numNonObjptrsRet, uint16_t *numObjptrsRet);
 
-bool isFrontierAligned (GC_state s, pointer p);
-
 pointer advanceToObjectData (GC_state s, pointer p);
 

Copied: mlton/branches/on-20050822-x86_64-branch/runtime/gc/platform.h (from rev 4168, mlton/branches/on-20050822-x86_64-branch/runtime/gc/virtual-memory.h)
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/virtual-memory.h	2005-11-07 02:39:08 UTC (rev 4168)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/platform.h	2005-11-08 02:59:15 UTC (rev 4171)
@@ -0,0 +1,48 @@
+/* Copyright (C) 1999-2005 Henry Cejtin, Matthew Fluet, Suresh
+ *    Jagannathan, and Stephen Weeks.
+ * Copyright (C) 1997-2000 NEC Research Institute.
+ *
+ * MLton is released under a BSD-style license.
+ * See the file MLton-LICENSE for details.
+ */
+
+/* ---------------------------------------------------------------- */
+/*                        Virtual Memory                            */
+/* ---------------------------------------------------------------- */
+
+/* GC_displayMem displays the virtual memory mapping to stdout.  
+ * It is used to diagnose memory problems. 
+ */
+void GC_displayMem (void);
+
+void *GC_mmapAnon (void *start, size_t length);
+void *GC_mmapAnon_safe (void *start, size_t length);
+void *GC_mmapAnon_safe_protect (void *start, size_t length, 
+                                size_t dead_low, size_t dead_high);
+void *GC_mremap (void *start, size_t oldLength, size_t newLength);
+void GC_release (void *base, size_t length);
+void GC_decommit (void *base, size_t length);
+
+size_t GC_pageSize (void);
+size_t GC_totalRam (void);
+size_t GC_availRam (void);
+
+
+/* ---------------------------------------------------------------- */
+/*                        Text Segment                              */
+/* ---------------------------------------------------------------- */
+
+void *GC_getTextEnd (void);
+void *GC_getTextStart (void);
+
+/* ---------------------------------------------------------------- */
+/*                        SigProf Handler                           */
+/* ---------------------------------------------------------------- */
+
+void GC_setSigProfHandler (struct sigaction *sa);
+
+/* ---------------------------------------------------------------- */
+/*                        Misc                                      */
+/* ---------------------------------------------------------------- */
+
+void GC_setCygwinUseMmap (bool b);

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/profiling.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/profiling.c	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/profiling.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -340,7 +340,6 @@
 
 static void initProfilingTime (GC_state s) {
   struct sigaction sa;
-  uint32_t sourceSeqsIndex;
 
   s->profiling.data = GC_profileNew (s);
   initTextSources (s);
@@ -359,7 +358,7 @@
    */
   handleSigProfState = s;
   sigemptyset (&sa.sa_mask);
-  setSigProfHandler (&sa);
+  GC_setSigProfHandler (&sa);
   unless (sigaction (SIGPROF, &sa, NULL) == 0)
     diee ("initProfilingTime: sigaction failed");
   /* Start the SIGPROF timer. */

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/profiling.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/profiling.h	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/profiling.h	2005-11-08 02:59:15 UTC (rev 4171)
@@ -81,6 +81,5 @@
 void GC_profileInc (GC_state s, size_t amount);
 void GC_profileAllocInc (GC_state s, size_t amount);
 
-void GC_handleSigProf (pointer pc);
 void initProfiling (GC_state s);
 

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/signals.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/signals.c	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/signals.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -17,7 +17,7 @@
   static stack_t altstack;
   size_t ss_size = align (SIGSTKSZ, s->sysvals.pageSize);
   size_t psize = s->sysvals.pageSize;
-  void *ss_sp = GC_mmap_safe_protect (NULL, 2 * ss_size, psize, psize);
+  void *ss_sp = GC_mmapAnon_safe_protect (NULL, 2 * ss_size, psize, psize);
   altstack.ss_sp = (unsigned char*)ss_sp + ss_size;
   altstack.ss_size = ss_size;
   altstack.ss_flags = 0;

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/sources.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/sources.c	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/sources.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -58,8 +58,8 @@
 
   sortSourceLabels (s);
   /* Initialize s->sourceMaps.textSources. */
-  s->sourceMaps.textEnd = (pointer)(getTextEnd());
-  s->sourceMaps.textStart = (pointer)(getTextStart());
+  s->sourceMaps.textEnd = (pointer)(GC_getTextEnd());
+  s->sourceMaps.textStart = (pointer)(GC_getTextStart());
   if (ASSERT)
     for (i = 0; i < s->sourceMaps.sourceLabelsLength; i++) {
       pointer label;

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/switch-thread.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/switch-thread.c	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/switch-thread.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -35,7 +35,7 @@
     getThreadCurrent(s)->bytesNeeded = ensureBytesFree;
     switchToThread (s, pointerToObjptr((pointer)t, s->heap.start));
     s->atomicState--;
-    switchToHandlerThreadIfNonAtomicAndSignalPending (s);
+    switchToSignalHandlerThreadIfNonAtomicAndSignalPending (s);
     ensureInvariantForMutator (s, FALSE);
     assert (invariantForMutatorFrontier(s));
     assert (invariantForMutatorStack(s));
@@ -49,7 +49,7 @@
     getThreadCurrent(s)->bytesNeeded = ensureBytesFree;
     switchToThread (s, pointerToObjptr((pointer)t, s->heap.start));
     s->atomicState--;
-    switchToHandlerThreadIfNonAtomicAndSignalPending (s);
+    switchToSignalHandlerThreadIfNonAtomicAndSignalPending (s);
     /* BEGIN: ensureInvariantForMutator */
     if (not (invariantForMutatorFrontier(s))
         or not (invariantForMutatorStack(s))) {

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/thread.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/thread.c	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/thread.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -30,6 +30,10 @@
 
     splitHeader (s, GC_THREAD_HEADER, NULL, NULL, &numNonObjptrs, &numObjptrs);
     check = GC_NORMAL_HEADER_SIZE + sizeofNormalNoHeader (s, numNonObjptrs, numObjptrs);
+    if (DEBUG_DETAILED) 
+      fprintf (stderr,
+               "sizeofThread: res = %zu  check = %zu\n",
+               res, check);
     assert (check == res);
   }
   /* The following assert depends on struct GC_thread being the right

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/virtual-memory.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/virtual-memory.c	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/virtual-memory.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -18,14 +18,3 @@
     return;
   memcpy (dst, src, size);
 }
-
-void *GC_mmapAnon_safe (void *p, size_t length) {
-  void *result;
-
-  result = GC_mmapAnon (p, length);
-  if ((void*)-1 == result) {
-    showMem ();
-    die ("Out of memory.");
-  }
-  return result;
-}

Deleted: mlton/branches/on-20050822-x86_64-branch/runtime/gc/virtual-memory.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/virtual-memory.h	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/virtual-memory.h	2005-11-08 02:59:15 UTC (rev 4171)
@@ -1,27 +0,0 @@
-/* Copyright (C) 1999-2005 Henry Cejtin, Matthew Fluet, Suresh
- *    Jagannathan, and Stephen Weeks.
- * Copyright (C) 1997-2000 NEC Research Institute.
- *
- * MLton is released under a BSD-style license.
- * See the file MLton-LICENSE for details.
- */
-
-/* showMem displays the virtual memory mapping to stdout.  
- * It is used to diagnose memory problems. 
- */
-void showMem (void);
-
-void *GC_mmapAnon (void *start, size_t length);
-void *GC_mmapAnon_safe (void *start, size_t length);
-void *GC_mmap (void *start, size_t length);
-void *GC_mmap_safe (void *start, size_t length);
-void *GC_mmap_safe_protect (void *start, size_t length, 
-                            size_t dead_low, size_t dead_high);
-void GC_munmap (void *start, size_t length);
-void *GC_mremap (void *start, size_t oldLength, size_t newLength);
-void GC_release (void *base, size_t length);
-void GC_decommit (void *base, size_t length);
-
-void *getTextEnd (void);
-void *getTextStart (void);
-void setSigProfHandler (struct sigaction *sa);

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/weak.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/weak.c	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/weak.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -15,7 +15,7 @@
     uint16_t numNonObjptrs, numObjptrs;
 
     splitHeader (s, GC_WEAK_GONE_HEADER, NULL, NULL, &numNonObjptrs, &numObjptrs);
-    check = GC_NORMAL_HEADER_SIZE + sizeofNormalNoHeader (s, numNonObjptrs, numObjptrs);
+    check = GC_NORMAL_HEADER_SIZE + sizeofWeakNoHeader (s, numNonObjptrs, numObjptrs);
     assert (check == res);
   }
   /* The following assert depends on struct GC_weak being the right

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/world.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/world.c	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/world.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -75,7 +75,7 @@
   (*s->saveGlobals) (fd);
 }
 
-void GC_saveWorldToFD (GC_state s, int fd) {
+void GC_saveWorld (GC_state s, int fd) {
   enter (s);
   saveWorldToFD (s, fd);
   leave (s);

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/world.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/world.h	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/world.h	2005-11-08 02:59:15 UTC (rev 4171)
@@ -9,4 +9,3 @@
 void loadWorldFromFD (GC_state s, int fd);
 void loadWorldFromFileName (GC_state s, char *fileName);
 void saveWorldToFD (GC_state s, int fd);
-void GC_saveWorldToFD (GC_state s, int fd);

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc.c	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -7,12 +7,10 @@
  */
 
 #define MLTON_GC_INTERNAL
-#include "gc.h"
+#include "platform.h"
 #undef MLTON_GC_INTERNAL
 #include "gc/rusage.h"
-#include "gc/virtual-memory.h"
 
-#include "gc/debug.c"
 #include "gc/virtual-memory.c"
 #include "gc/align.c"
 #include "gc/read_write.c"
@@ -47,6 +45,7 @@
 #include "gc/new-object.c"
 #include "gc/object-size.c"
 #include "gc/object.c"
+#include "gc/objptr.c"
 #include "gc/pack.c"
 #include "gc/pointer.c"
 #include "gc/profiling.c"

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc.h	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc.h	2005-11-08 02:59:15 UTC (rev 4171)
@@ -15,10 +15,11 @@
 struct GC_state;
 typedef struct GC_state *GC_state;
 
+#if (defined (MLTON_GC_INTERNAL))
+
 #define GC_MODEL_NATIVE32
 
-#if (defined (MLTON_GC_INTERNAL))
-
+#include "gc/align.h"
 #include "gc/model.h"
 #include "gc/pointer.h"
 #include "gc/objptr.h"
@@ -72,6 +73,8 @@
 
 #endif /* (defined (MLTON_GC_INTERNAL)) */
 
+#include "gc/debug.h"
+#include "gc/platform.h"
 #include "gc/gc_state_exports.h"
 #include "gc/exports.h"
 

Added: mlton/branches/on-20050822-x86_64-branch/runtime/gen/gen-types.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gen/gen-types.c	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gen/gen-types.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -0,0 +1,125 @@
+/* Copyright (C) 2004-2005 Henry Cejtin, Matthew Fluet, Suresh
+ *    Jagannathan, and Stephen Weeks.
+ *
+ * MLton is released under a BSD-style license.
+ * See the file MLton-LICENSE for details.
+ */
+
+#include "util.h"
+
+#define prefixLines 26
+static char* prefix[prefixLines] = {
+  "/* Copyright (C) 2004-2005 Henry Cejtin, Matthew Fluet, Suresh",
+  " *    Jagannathan, and Stephen Weeks.",
+  " *",
+  " * MLton is released under a BSD-style license.",
+  " * See the file MLton-LICENSE for details.",
+  " */",
+  "",
+  "/* Can't use _TYPES_H_ because MSVCRT uses it.  So, we use _MLTON_TYPES_H_. */",
+  "",
+  "#ifndef _MLTON_TYPES_H_",
+  "#define _MLTON_TYPES_H_",
+  "",
+  "/* We need these because in header files for exported SML functions, types.h is",
+  " * included without platform.h.",
+  " */",
+  "#ifndef _ISOC99_SOURCE",
+  "#define _ISOC99_SOURCE",
+  "#endif",
+  "#if (defined (__OpenBSD__))",
+  "#include <inttypes.h>",
+  "#elif (defined (__sun__))",
+  "#include <sys/int_types.h>",
+  "#else",
+  "#include <stdint.h>",
+  "#endif",
+  ""
+};
+
+#define stdtypesLines 21
+static char* stdtypes[stdtypesLines] = {
+  "typedef int8_t Int8;",
+  "typedef int16_t Int16;",
+  "typedef int32_t Int32;",
+  "typedef int64_t Int64;",
+  "typedef unsigned char* Pointer;",
+  "typedef float Real32;",
+  "typedef double Real64;",
+  "typedef uint8_t Word8;",
+  "typedef uint16_t Word16;",
+  "typedef uint32_t Word32;",
+  "typedef uint64_t Word64;",
+  "",
+  "typedef Int8 WordS8;",
+  "typedef Int16 WordS16;",
+  "typedef Int32 WordS32;",
+  "typedef Int64 WordS64;",
+  "",
+  "typedef Word8 WordU8;",
+  "typedef Word16 WordU16;",
+  "typedef Word32 WordU32;",
+  "typedef Word64 WordU64;"
+};
+
+#define systype(t, bt, name)               \
+  do {                                     \
+  writeString (fd, "typedef ");            \
+  writeString (fd, bt);                    \
+  writeUintmaxU (fd, CHAR_BIT * sizeof(t));\
+  writeString (fd, " ");                   \
+  writeString (fd, name);                  \
+  writeString (fd, ";");                   \
+  writeNewline (fd);                       \
+  } while (0)
+
+#define suffixLines 2
+static char* suffix[suffixLines] = {
+  "",
+  "#endif /* _MLTON_TYPES_H_ */"
+};
+
+int main (int argc, char* argv[]) {
+  int fd;
+
+  fd = open_safe ("types.h", O_RDWR | O_CREAT, 0);
+  for (int i = 0; i < prefixLines; i++) {
+    writeString (fd, prefix[i]);
+    writeNewline (fd);
+  }
+  for (int i = 0; i < stdtypesLines; i++) {
+    writeString (fd, stdtypes[i]);
+    writeNewline (fd);
+  }
+  writeNewline (fd);
+  systype(char, "Word", "Char");
+  systype(int, "Int", "Int");
+  systype(off_t, "Int", "Position");
+  systype(double, "Real", "Real");
+  systype(unsigned int, "Word", "Word");
+  systype(int, "Int", "Bool");
+  writeNewline (fd);
+  systype(unsigned char*, "Word", "Cpointer");
+  systype(char*, "Word", "Cstring");
+  systype(char**, "Word", "CstringArray");
+  systype(size_t, "Int", "Size");
+  systype(ssize_t, "Int", "Ssize");
+  writeNewline (fd);
+  systype(int, "Int", "Fd");
+  systype(tcflag_t, "Word", "Flag");
+  systype(gid_t, "Word", "Gid");
+  systype(mode_t, "Int", "Mode");
+  systype(pid_t, "Int", "Pid");
+  systype(int, "Int", "Resource");
+  systype(rlim_t, "Word", "Rlimit");
+  systype(int, "Int", "Signal");
+  systype(speed_t, "Word", "Speed");
+  systype(int, "Int", "Status");
+  systype(uid_t, "Word", "Uid");
+  writeNewline (fd);
+  for (int i = 0; i < suffixLines; i++) {
+    writeString (fd, suffix[i]);
+    writeNewline (fd);
+  }
+  return 0;
+}

Copied: mlton/branches/on-20050822-x86_64-branch/runtime/platform/displayMem.linux.c (from rev 4167, mlton/branches/on-20050822-x86_64-branch/runtime/platform/showMem.linux.c)
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/platform/showMem.linux.c	2005-11-07 02:34:33 UTC (rev 4167)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/platform/displayMem.linux.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -0,0 +1,6 @@
+void GC_displayMem () {
+        static char buffer[256];
+
+        sprintf (buffer, "/bin/cat /proc/%d/maps\n", (int)(getpid ()));
+        system (buffer);
+}

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/platform/getText.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/platform/getText.c	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/platform/getText.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -2,9 +2,9 @@
 extern char _start;
 extern char etext;
 
-void *getTextStart () {
+void *GC_getTextStart () {
         return &_start;
 }
-void *getTextEnd () {
+void *GC_getTextEnd () {
         return &etext;
 }

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-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/platform/linux.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -4,9 +4,9 @@
 
 #include "getText.c"
 #include "mkdir2.c"
-#include "showMem.linux.c"
-#include "ssmmap.c"
-#include "totalRam.sysconf.c"
+#include "displayMem.linux.c"
+#include "mmap-protect.c"
+#include "sysconf.c"
 #include "use-mmap.c"
 
 #ifndef EIP
@@ -49,50 +49,11 @@
 #endif
 }
 
-void setSigProfHandler (struct sigaction *sa) {
+void GC_setSigProfHandler (struct sigaction *sa) {
         sa->sa_flags = SA_ONSTACK | SA_RESTART | SA_SIGINFO;
         sa->sa_sigaction = (void (*)(int, siginfo_t*, void*))catcher;
 }
 
-/* Work around Linux kernel bugs associated with the user and system times. */
-
-int fixedGetrusage (int who, struct rusage *rup) {
-        struct tms      tbuff;
-        int             res;
-        clock_t         user,
-                        sys;
-        static bool     first = TRUE;
-        static long     hz;
-
-        if (first) {
-                first = FALSE;
-                hz = sysconf (_SC_CLK_TCK);
-        }
-        res = getrusage (who, rup);
-        unless (res == 0)
-                return (res);
-        if (times (&tbuff) == -1)
-                diee ("Impossible: times() failed");
-        switch (who) {
-        case RUSAGE_SELF:
-                user = tbuff.tms_utime;
-                sys = tbuff.tms_stime;
-                break;
-        case RUSAGE_CHILDREN:
-                user = tbuff.tms_cutime;
-                sys = tbuff.tms_cstime;
-                break;
-        default:
-                die ("getrusage() accepted unknown who: %d", who);
-                exit (1);  /* needed to keep gcc from whining. */
-        }
-        rup->ru_utime.tv_sec = user / hz;
-        rup->ru_utime.tv_usec = (user % hz) * (1000000 / hz);
-        rup->ru_stime.tv_sec = sys / hz;
-        rup->ru_stime.tv_usec = (sys % hz) * (1000000 / hz);
-        return (0);
-}
-
 /* We need the value of MREMAP_MAYMOVE, which should come from sys/mman.h, but
  * isn't there.  It is in linux/mman.h, but we can't #include that here, because
  * kernel headers don't mix with system headers.  We could create a separate
@@ -102,8 +63,8 @@
  */
 #define MREMAP_MAYMOVE 1
 
-void *remap (void *old,  size_t oldSize, size_t newSize) {
-        return mremap (old, oldSize, newSize, MREMAP_MAYMOVE);
+void *GC_mremap (void *start, size_t oldLength, size_t newLength) {
+        return mremap (start, oldLength, newLength, MREMAP_MAYMOVE);
 }
 
 /* ------------------------------------------------- */

Copied: mlton/branches/on-20050822-x86_64-branch/runtime/platform/mmap-protect.c (from rev 4167, mlton/branches/on-20050822-x86_64-branch/runtime/platform/ssmmap.c)
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/platform/ssmmap.c	2005-11-07 02:34:33 UTC (rev 4167)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/platform/mmap-protect.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -0,0 +1,16 @@
+void *GC_mmapAnon_safe_protect (void *start, size_t length,
+                                size_t dead_low, size_t dead_high) {
+        void *base,*low,*result,*high;
+
+        base = GC_mmapAnon_safe (start, length + dead_low + dead_high);
+        low = base;
+        if (mprotect (low, dead_low, PROT_NONE))
+                diee ("mprotect failed");
+        result = low + dead_low;
+        if (mprotect (result, length, PROT_READ | PROT_WRITE | PROT_EXEC))
+                diee ("mprotect failed");
+        high = result + length;
+        if (mprotect (high, dead_high, PROT_NONE))
+                diee ("mprotect failed");
+        return result;
+}

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/platform/mmap.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/platform/mmap.c	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/platform/mmap.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -1,13 +1,13 @@
-static inline void *mmapAnonMmap (void *start, size_t length) {
+static inline void *mmapAnon (void *start, size_t length) {
         return mmap (start, length, PROT_READ | PROT_WRITE, 
                         MAP_PRIVATE | MAP_ANON, -1, 0);
 }
 
-static void smunmap (void *base, size_t length) {
+static void munmap_safe (void *base, size_t length) {
         if (DEBUG_MEM)
-                fprintf (stderr, "smunmap (0x%08x, %s)\n",
+                fprintf (stderr, "munmap_safe (0x%08x, %s)\n",
                                 (uint)base,
-                                uintToCommaString (length));
+                                uintmaxToCommaString (length));
         assert (base != NULL);
         if (0 == length)
                 return;

Deleted: mlton/branches/on-20050822-x86_64-branch/runtime/platform/ssmmap.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/platform/ssmmap.c	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/platform/ssmmap.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -1,15 +0,0 @@
-void *ssmmap (size_t length, size_t dead_low, size_t dead_high) {
-        void *base,*low,*result,*high;
-
-        base = smmap (length + dead_low + dead_high);
-        low = base;
-        if (mprotect (low, dead_low, PROT_NONE))
-                diee ("mprotect failed");
-        result = low + dead_low;
-        if (mprotect (result, length, PROT_READ | PROT_WRITE | PROT_EXEC))
-                diee ("mprotect failed");
-        high = result + length;
-        if (mprotect (high, dead_high, PROT_NONE))
-                diee ("mprotect failed");
-        return result;
-}

Copied: mlton/branches/on-20050822-x86_64-branch/runtime/platform/sysconf.c (from rev 4167, mlton/branches/on-20050822-x86_64-branch/runtime/platform/totalRam.sysconf.c)
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/platform/totalRam.sysconf.c	2005-11-07 02:34:33 UTC (rev 4167)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/platform/sysconf.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -0,0 +1,22 @@
+size_t GC_pageSize () {
+  long int tmp;
+
+  tmp = sysconf (_SC_PAGESIZE);
+  return (size_t)tmp;
+}
+
+size_t GC_totalRam () {
+  size_t pageSize = GC_pageSize ();
+  long int tmp;
+
+  tmp = sysconf (_SC_PHYS_PAGES);
+  return pageSize * (size_t)tmp;
+}
+
+size_t GC_availRam () {
+  size_t pageSize = GC_pageSize ();
+  long int tmp;
+
+  tmp = sysconf (_SC_AVPHYS_PAGES);
+  return pageSize * (size_t)tmp;
+}

Deleted: mlton/branches/on-20050822-x86_64-branch/runtime/platform/totalRam.sysconf.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/platform/totalRam.sysconf.c	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/platform/totalRam.sysconf.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -1,8 +0,0 @@
-W32 totalRam (GC_state s) {
-        W32 maxMem;
-        W64 tmp;
-
-        maxMem = 0x100000000llu - s->pageSize;
-        tmp = sysconf (_SC_PHYS_PAGES) * (W64)s->pageSize;
-        return (tmp >= maxMem) ? maxMem: (W32)tmp;
-}

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/platform/use-mmap.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/platform/use-mmap.c	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/platform/use-mmap.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -1,13 +1,24 @@
 #include "mmap.c"
 
-void decommit (void *base, size_t length) {
-        smunmap (base, length);
+void GC_decommit (void *base, size_t length) {
+        munmap_safe (base, length);
 }
 
-void release (void *base, size_t length) {
-        smunmap (base, length);
+void GC_release (void *base, size_t length) {
+        munmap_safe (base, length);
 }
 
-void *mmapAnon (void *start, size_t length) {
-        return mmapAnonMmap (start, length);
+void *GC_mmapAnon (void *start, size_t length) {
+        return mmapAnon (start, length);
 }
+
+void *GC_mmapAnon_safe (void *p, size_t length) {
+        void *result;
+
+        result = GC_mmapAnon (p, length);
+        if ((void*)-1 == result) {
+                GC_displayMem ();
+                die ("Out of memory.");
+        }
+        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-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/platform.c	2005-11-08 02:59:15 UTC (rev 4171)
@@ -7,3 +7,23 @@
 
 #include "platform.h"
 
+Bool MLton_Platform_CygwinUseMmap = FALSE;
+
+void GC_setCygwinUseMmap (bool b) {
+  MLton_Platform_CygwinUseMmap = b;
+}
+
+extern char **environ; /* for Posix_ProcEnv_environ */
+
+void MLton_init (int argc, char **argv, GC_state s) {
+  int start;
+
+  Posix_ProcEnv_environ = (CstringArray)environ;
+  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_argc = argc - start;
+  CommandLine_argv = (uint)(argv + start);
+}
+

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/platform.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/platform.h	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/platform.h	2005-11-08 02:59:15 UTC (rev 4171)
@@ -114,22 +114,19 @@
 #endif
 #endif
 
-/* If HAS_TIME_PROFILING, then you must define these. */
-void *getTextStart ();
-void *getTextEnd ();
-
 #ifndef SPAWN_MODE
 #define SPAWN_MODE 0
 #endif
 
-enum {
-  DEBUG_MEM = FALSE,
-  DEBUG_SIGNALS = FALSE,
-};
-
 #include "types.h"
 
 /* ---------------------------------------------------------------- */
+/*                        Utility libraries                         */
+/* ---------------------------------------------------------------- */
+
+int mkdir2 (const char *pathname, mode_t mode);
+
+/* ---------------------------------------------------------------- */
 /*                         MLton libraries                          */
 /* ---------------------------------------------------------------- */
 
@@ -153,31 +150,31 @@
 /*                       Date                        */
 /* ------------------------------------------------- */
 
-Int Date_Tm_sec();
-Int Date_Tm_min();
-Int Date_Tm_hour();
-Int Date_Tm_mday();
-Int Date_Tm_mon();
-Int Date_Tm_year();
-Int Date_Tm_wday();
-Int Date_Tm_yday();
-Int Date_Tm_isdst();
-void Date_Tm_setSec(Int x);
-void Date_Tm_setMin(Int x);
-void Date_Tm_setHour(Int x);
-void Date_Tm_setMday(Int x);
-void Date_Tm_setMon(Int x);
-void Date_Tm_setYear(Int x);
-void Date_Tm_setWday(Int x);
-void Date_Tm_setYday(Int x);
-void Date_Tm_setIsdst(Int x);
+Int Date_Tm_sec (void);
+Int Date_Tm_min (void);
+Int Date_Tm_hour (void);
+Int Date_Tm_mday (void);
+Int Date_Tm_mon (void);
+Int Date_Tm_year (void);
+Int Date_Tm_wday (void);
+Int Date_Tm_yday (void);
+Int Date_Tm_isdst (void);
+void Date_Tm_setSec (Int x);
+void Date_Tm_setMin (Int x);
+void Date_Tm_setHour (Int x);
+void Date_Tm_setMday (Int x);
+void Date_Tm_setMon (Int x);
+void Date_Tm_setYear (Int x);
+void Date_Tm_setWday (Int x);
+void Date_Tm_setYday (Int x);
+void Date_Tm_setIsdst (Int x);
 
-Cstring Date_ascTime();
-void Date_gmTime(Pointer p);
-Int Date_localOffset();
-void Date_localTime(Pointer p);
-Int Date_mkTime();
-Int Date_strfTime(Pointer buf, Int n, NullString fmt);
+Cstring Date_ascTime (void);
+void Date_gmTime (Pointer p);
+Int Date_localOffset (void);
+void Date_localTime (Pointer p);
+Int Date_mkTime (void);
+Int Date_strfTime (Pointer buf, Int n, Pointer fmt);
 
 /* ------------------------------------------------- */
 /*                       Debug                       */
@@ -209,7 +206,7 @@
  * overwrites them.
  */
 void IEEEReal_setRoundingMode (Int mode);
-Int IEEEReal_getRoundingMode ();
+Int IEEEReal_getRoundingMode (void);
 
 /* ------------------------------------------------- */
 /*                      IntInf                       */
@@ -260,10 +257,10 @@
 /* print a bug message and exit (2) */
 void MLton_bug (Pointer msg);
 
-Int MLton_errno ();
+Int MLton_errno (void);
 /* halt the machine */
 void MLton_exit (Int status);
-Word MLton_random ();
+Word MLton_random (void);
 Word MLton_size (Pointer p);
 
 /* ---------------------------------- */
@@ -309,7 +306,7 @@
 void MLton_Profile_Data_write (Pointer data, Word fd);
 
 Pointer MLton_Profile_current (void);
-void MLton_Profile_done ();
+void MLton_Profile_done (void);
 void MLton_Profile_setCurrent (Pointer d);
 
 /* ---------------------------------- */
@@ -317,8 +314,8 @@
 /* ---------------------------------- */
 
 Pid MLton_Process_cwait (Pid p, Pointer s);
-Int MLton_Process_spawne (NullString p, Pointer a, Pointer e);
-Int MLton_Process_spawnp (NullString p, Pointer a);
+Int MLton_Process_spawne (Pointer p, Pointer a, Pointer e);
+Int MLton_Process_spawnp (Pointer p, Pointer a);
 
 /* ---------------------------------- */
 /*            MLton.Rlimit            */
@@ -356,8 +353,8 @@
 #define MLton_Rlimit_infinity RLIM_INFINITY
 
 Int MLton_Rlimit_get (Resource r);
-Rlimit MLton_Rlimit_getHard ();
-Rlimit MLton_Rlimit_getSoft ();
+Rlimit MLton_Rlimit_getHard (void);
+Rlimit MLton_Rlimit_getSoft (void);
 Int MLton_Rlimit_set (Resource r, Rlimit hard, Rlimit soft);
 
 /* ------------------------------------------------- */
@@ -368,7 +365,7 @@
 #define OS_IO_POLLPRI POLLPRI
 #define OS_IO_POLLOUT POLLOUT
 
-Cstring OS_FileSys_tmpnam ();
+Cstring OS_FileSys_tmpnam (void);
 Int OS_IO_poll (Int *fds, Word *eventss, Int n, Int timeout, Word *reventss);
 
 /* ------------------------------------------------- */
@@ -386,9 +383,9 @@
 /*            Posix.Error             */
 /* ---------------------------------- */
 
-void Posix_Error_clearErrno ();
-Int Posix_Error_gettErrno ();
-Cstring Posix_Error_strerror (Syserror n);
+void Posix_Error_clearErrno (void);
+Int Posix_Error_gettErrno (void);
+Cstring Posix_Error_strerror (Int n);
 
 #define Posix_Error_acces EACCES
 #define Posix_Error_again EAGAIN
@@ -529,50 +526,40 @@
 #define Posix_FileSys_PRIO_IO 0
 #endif
 
-Int Posix_FileSys_Dirstream_closedir (Dirstream d);
-Dirstream Posix_FileSys_DirStream_opendir (NullString p);
-Cstring Posix_FileSys_Dirstream_readdir (Dirstream d);
-void Posix_FileSys_Dirstream_rewinddir (Dirstream p);
+Int Posix_FileSys_Dirstream_closedir (Cpointer d);
+Cpointer Posix_FileSys_DirStream_opendir (Pointer p);
+Cstring Posix_FileSys_Dirstream_readdir (Cpointer d);
+void Posix_FileSys_Dirstream_rewinddir (Cpointer p);
 
 Int Posix_FileSys_Stat_fstat (Fd f);
-Int Posix_FileSys_Stat_lstat (NullString f);
-Int Posix_FileSys_Stat_stat (NullString f);
-Word Posix_FileSys_Stat_dev ();
-Int Posix_FileSys_Stat_ino ();
-Word Posix_FileSys_Stat_mode ();
-Int Posix_FileSys_Stat_nlink ();
-Word Posix_FileSys_Stat_uid ();
-Word Posix_FileSys_Stat_gid ();
-Word Posix_FileSys_Stat_rdev ();
-Position Posix_FileSys_Stat_size ();
-Int Posix_FileSys_Stat_atime ();
-Int Posix_FileSys_Stat_mtime ();
-Int Posix_FileSys_Stat_ctime ();
+Int Posix_FileSys_Stat_lstat (Pointer f);
+Int Posix_FileSys_Stat_stat (Pointer f);
+Word Posix_FileSys_Stat_dev (void);
+Int Posix_FileSys_Stat_ino (void);
+Word Posix_FileSys_Stat_mode (void);
+Int Posix_FileSys_Stat_nlink (void);
+Word Posix_FileSys_Stat_uid (void);
+Word Posix_FileSys_Stat_gid (void);
+Word Posix_FileSys_Stat_rdev (void);
+Position Posix_FileSys_Stat_size (void);
+Int Posix_FileSys_Stat_atime (void);
+Int Posix_FileSys_Stat_mtime (void);
+Int Posix_FileSys_Stat_ctime (void);
 
 void Posix_FileSys_Utimbuf_setActime (Int x);
 void Posix_FileSys_Utimbuf_setModTime (Int x);
-Int Posix_FileSys_Utimbuf_utime (NullString s);
+Int Posix_FileSys_Utimbuf_utime (Pointer s);
 
-Int Posix_FileSys_access (NullString f, Word w);
-Int Posix_FileSys_chdir (NullString p);
-Int Posix_FileSys_chmod (NullString p, Mode m);
-Int Posix_FileSys_chown (NullString 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 (NullString p1, NullString p2);
-Int Posix_FileSys_mkdir (NullString p, Word w);
-Int Posix_FileSys_mkfifo (NullString p, Word w);
-Int Posix_FileSys_open (NullString p, Word w, Mode m);
-Int Posix_FileSys_pathconf (NullString p, Int n);
-Int Posix_FileSys_readlink (NullString p, Pointer b, Int);
-Int Posix_FileSys_rename (NullString p1, NullString p2);
-Int Posix_FileSys_rmdir (NullString p);
-Int Posix_FileSys_symlink (NullString p1, NullString 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);
+Int Posix_FileSys_pathconf (Pointer p, Int n);
+Int Posix_FileSys_readlink (Pointer p, Pointer b, Int);
+Int Posix_FileSys_rename (Pointer p1, Pointer p2);
+Int Posix_FileSys_rmdir (Pointer p);
+Int Posix_FileSys_symlink (Pointer p1, Pointer p2);
 Word Posix_FileSys_umask (Word w);
-Word Posix_FileSys_unlink (NullString p);
+Word Posix_FileSys_unlink (Pointer p);
 
 Bool Posix_FileSys_ST_isDir (Word w);
 Bool Posix_FileSys_ST_isChr (Word w);
@@ -606,11 +593,11 @@
 #define Posix_IO_FD_cloexec FD_CLOEXEC
 
 Int Posix_IO_FLock_fcntl (Fd f, Int cmd);
-Int Posix_IO_FLock_type ();
-Int Posix_IO_FLock_whence ();
-Position Posix_IO_FLock_start ();
-Position Posix_IO_FLock_len ();
-Int Posix_IO_FLock_pid ();
+Int Posix_IO_FLock_type (void);
+Int Posix_IO_FLock_whence (void);
+Position Posix_IO_FLock_start (void);
+Position Posix_IO_FLock_len (void);
+Int Posix_IO_FLock_pid (void);
 void Posix_IO_FLock_setType (Int x);
 void Posix_IO_FLock_setWhence (Int x);
 void Posix_IO_FLock_setStart (Position x);
@@ -664,38 +651,38 @@
   Posix_ProcEnv_numgroups = 100,
 };
 
-Pid Posix_ProcEnv_getpid ();
-Pid Posix_ProcEnv_getppid ();
-Uid Posix_ProcEnv_getuid ();
-Uid Posix_ProcEnv_geteuid ();
-Gid Posix_ProcEnv_getgid ();
-Gid Posix_ProcEnv_getegid ();
-Int Posix_ProcEnv_setenv (NullString s, NullString v);
+Pid Posix_ProcEnv_getpid (void);
+Pid Posix_ProcEnv_getppid (void);
+Uid Posix_ProcEnv_getuid (void);
+Uid Posix_ProcEnv_geteuid (void);
+Gid Posix_ProcEnv_getgid (void);
+Gid Posix_ProcEnv_getegid (void);
+Int Posix_ProcEnv_setenv (Pointer s, Pointer v);
 Int Posix_ProcEnv_setuid (Uid u);
 Int Posix_ProcEnv_setgid (Gid g);
 Int Posix_ProcEnv_getgroups (Pointer groups);
-Cstring Posix_ProcEnv_getlogin ();
-Pid Posix_ProcEnv_getpgrp ();
-Pid Posix_ProcEnv_setsid ();
+Cstring Posix_ProcEnv_getlogin (void);
+Pid Posix_ProcEnv_getpgrp (void);
+Pid Posix_ProcEnv_setsid (void);
 Int Posix_ProcEnv_setpgid (Pid p, Gid g);
 
-Int Posix_ProcEnv_Uname_uname ();
-Cstring Posix_ProcEnv_Uname_sysname ();
-Cstring Posix_ProcEnv_Uname_nodename ();
-Cstring Posix_ProcEnv_Uname_release ();
-Cstring Posix_ProcEnv_Uname_version ();
-Cstring Posix_ProcEnv_Uname_machine ();
+Int Posix_ProcEnv_Uname_uname (void);
+Cstring Posix_ProcEnv_Uname_sysname (void);
+Cstring Posix_ProcEnv_Uname_nodename (void);
+Cstring Posix_ProcEnv_Uname_release (void);
+Cstring Posix_ProcEnv_Uname_version (void);
+Cstring Posix_ProcEnv_Uname_machine (void);
 
-Int Posix_ProcEnv_Tms_utime ();
-Int Posix_ProcEnv_Tms_stime ();
-Int Posix_ProcEnv_Tms_cutime ();
-Int Posix_ProcEnv_Tms_cstime ();
+Int Posix_ProcEnv_Tms_utime (void);
+Int Posix_ProcEnv_Tms_stime (void);
+Int Posix_ProcEnv_Tms_cutime (void);
+Int Posix_ProcEnv_Tms_cstime (void);
 
-Cstring Posix_ProcEnv_ctermid ();
-Cstring Posix_ProcEnv_getenv (NullString s);
+Cstring Posix_ProcEnv_ctermid (void);
+Cstring Posix_ProcEnv_getenv (Pointer s);
 Bool Posix_ProcEnv_isatty (Fd f);
 Int Posix_ProcEnv_sysconf (Int i);
-Int Posix_ProcEnv_times ();
+Int Posix_ProcEnv_times (void);
 Cstring Posix_ProcEnv_ttyname (Fd f);
 
 /* ---------------------------------- */
@@ -729,12 +716,12 @@
 #define Posix_Signal_vtalrm SIGVTALRM
 
 Int Posix_Process_alarm (Int i);
-Int Posix_Process_exece (NullString path, Pointer args, Pointer env);
-Int Posix_Process_execp (NullString file, Pointer args);
+Int Posix_Process_exece (Pointer path, Pointer args, Pointer env);
+Int Posix_Process_execp (Pointer file, Pointer args);
 void Posix_Process_exit (Int i);
-Pid Posix_Process_fork ();
+Pid Posix_Process_fork (void);
 Int Posix_Process_kill (Pid p, Signal s);
-Int Posix_Process_pause ();
+Int Posix_Process_pause (void);
 Int Posix_Process_sleep (Int i);
 Pid Posix_Process_waitpid (Pid p, Pointer s, Int i);
 Bool Posix_Process_ifExited (Status s);
@@ -765,27 +752,27 @@
 Bool Posix_Signal_isPending (Int signum);
 Int Posix_Signal_sigaddset (Int signum);
 Int Posix_Signal_sigdelset (Int signum);
-Int Posix_Signal_sigemptyset ();
-Int Posix_Signal_sigfillset ();
+Int Posix_Signal_sigemptyset (void);
+Int Posix_Signal_sigfillset (void);
 Int Posix_Signal_sigprocmask (Int how);
-Int Posix_Signal_sigsuspend ();
+Int Posix_Signal_sigsuspend (void);
 
 /* ---------------------------------- */
 /*            Posix.SysDB             */
 /* ---------------------------------- */
 
-Cstring Posix_SysDB_Passwd_name ();
-Uid Posix_SysDB_Passwd_uid ();
-Gid Posix_SysDB_Passwd_gid ();
-Cstring Posix_SysDB_Passwd_dir ();
-Cstring Posix_SysDB_Passwd_shell ();
+Cstring Posix_SysDB_Passwd_name (void);
+Uid Posix_SysDB_Passwd_uid (void);
+Gid Posix_SysDB_Passwd_gid (void);
+Cstring Posix_SysDB_Passwd_dir (void);
+Cstring Posix_SysDB_Passwd_shell (void);
 Bool Posix_SysDB_getpwnam (Pointer p);
 Bool Posix_SysDB_getpwuid (Uid u);
 Bool Posix_SysDB_getgrgid (Gid g);
-Bool Posix_SysDB_getgrnam (NullString s);
-Cstring Posix_SysDB_Group_name ();
-Gid Posix_SysDB_Group_gid ();
-CstringArray Posix_SysDB_Group_mem ();
+Bool Posix_SysDB_getgrnam (Pointer s);
+Cstring Posix_SysDB_Group_name (void);
+Gid Posix_SysDB_Group_gid (void);
+CstringArray Posix_SysDB_Group_mem (void);
 
 /* ---------------------------------- */
 /*             Posix.TTY              */
@@ -862,13 +849,13 @@
 #define Posix_TTY_TC_ioflush TCIOFLUSH
 #define Posix_TTY_TC_oflush TCOFLUSH
 
-Flag Posix_TTY_Termios_iflag ();
-Flag Posix_TTY_Termios_oflag ();
-Flag Posix_TTY_Termios_cflag ();
-Flag Posix_TTY_Termios_lflag ();
-Cstring Posix_TTY_Termios_cc ();
-Speed Posix_TTY_Termios_cfgetospeed ();
-Speed Posix_TTY_Termios_cfgetispeed ();
+Flag Posix_TTY_Termios_iflag (void);
+Flag Posix_TTY_Termios_oflag (void);
+Flag Posix_TTY_Termios_cflag (void);
+Flag Posix_TTY_Termios_lflag (void);
+Cstring Posix_TTY_Termios_cc (void);
+Speed Posix_TTY_Termios_cfgetospeed (void);
+Speed Posix_TTY_Termios_cfgetispeed (void);
 void Posix_TTY_Termios_setiflag (Flag f);
 void Posix_TTY_Termios_setoflag (Flag f);
 void Posix_TTY_Termios_setcflag (Flag f);
@@ -897,17 +884,17 @@
 /* ------------------------------------------------- */
 
 #if (defined (__MSVCRT__))
-void MLton_initSockets ();
+void MLton_initSockets (void);
 #else
-static inline void MLton_initSockets () {}
+static inline void MLton_initSockets (void) {}
 #endif
 
-#define NetHostDB_inAddrLen sizeof(struct in_addr)
+#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), \
-                                  sizeof(struct sockaddr_in6))))
+#define Socket_sockAddrLenMax max(sizeof (struct sockaddr), \
+                              max(sizeof (struct sockaddr_un), \
+                              max(sizeof (struct sockaddr_in), \
+                                  sizeof (struct sockaddr_in6))))
 #define Socket_AF_UNIX PF_UNIX
 #define Socket_AF_INET PF_INET
 #define Socket_AF_INET6 PF_INET6
@@ -956,21 +943,21 @@
 /*                      Thread                       */
 /* ------------------------------------------------- */
 
-Thread Thread_current ();
-void Thread_finishHandler ();
-void Thread_resetSignals ();
-Thread Thread_saved ();
-void Thread_setHandler (Thread t);
-void Thread_startHandler ();
-void Thread_switchTo (Thread t, Word ensureBytesFree);
+Pointer Thread_current (void);
+void Thread_finishSignalHandler (void);
+void Thread_resetSignals (void);
+Pointer Thread_saved (void);
+void Thread_setSignalHandler (Pointer t);
+void Thread_startSignalHandler (void);
+void Thread_switchTo (Pointer t, Word ensureBytesFree);
 
 /* ------------------------------------------------- */
 /*                       Time                        */
 /* ------------------------------------------------- */
 
-Int Time_gettimeofday ();
-Int Time_sec ();
-Int Time_usec ();
+Int Time_gettimeofday (void);
+Int Time_sec (void);
+Int Time_usec (void);
 
 /* ------------------------------------------------- */
 /*                      Windows                      */

Deleted: mlton/branches/on-20050822-x86_64-branch/runtime/types.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/types.h	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/types.h	2005-11-08 02:59:15 UTC (rev 4171)
@@ -1,78 +0,0 @@
-/* Copyright (C) 2004-2005 Henry Cejtin, Matthew Fluet, Suresh
- *    Jagannathan, and Stephen Weeks.
- *
- * MLton is released under a BSD-style license.
- * See the file MLton-LICENSE for details.
- */
-
-/* Can't use _TYPES_H_ because MSVCRT uses it.  So, we use _MLTON_TYPES_H_. */
-
-#ifndef _MLTON_TYPES_H_
-#define _MLTON_TYPES_H_
-
-/* We need these because in header files for exported SML functions, types.h is
- * included without platform.h.
- */
-#ifndef _ISOC99_SOURCE
-#define _ISOC99_SOURCE
-#endif
-#if (defined (__OpenBSD__))
-#include <inttypes.h>
-#elif (defined (__sun__))
-#include <sys/int_types.h>
-#else
-#include <stdint.h>
-#endif
-
-typedef int8_t Int8;
-typedef int16_t Int16;
-typedef int32_t Int32;
-typedef int64_t Int64;
-typedef pointer Pointer;
-typedef float Real32;
-typedef double Real64;
-typedef uint8_t Word8;
-typedef uint16_t Word16;
-typedef uint32_t Word32;
-typedef uint64_t Word64;
-
-typedef Int8 WordS8;
-typedef Int16 WordS16;
-typedef Int32 WordS32;
-typedef Int64 WordS64;
-
-typedef Word8 WordU8;
-typedef Word16 WordU16;
-typedef Word32 WordU32;
-typedef Word64 WordU64;
-
-/* !!! this stuff is all wrong: */
-typedef Int32 Int;
-typedef Real64 Real;
-typedef Word8 Char;
-typedef Word32 Word;
-typedef Int64 Position;
-
-typedef Int Bool;
-typedef Word Cpointer;
-typedef Word Cstring;
-typedef Word CstringArray;
-typedef Word Dirstream;
-typedef Int Fd;
-typedef Word Flag;
-typedef Word Gid;
-typedef Word Mode;
-typedef Word NullString;
-typedef Int Pid;
-typedef Int Resource;
-typedef Word Rlimit;
-typedef Int Signal;
-typedef Int Size;
-typedef Int Speed;
-typedef Int Ssize;
-typedef Int Status;
-typedef Int Syserror;
-typedef Pointer Thread;
-typedef Word Uid;
-
-#endif /* _MLTON_TYPES_H_ */

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/util.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/util.h	2005-11-07 22:23:36 UTC (rev 4170)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/util.h	2005-11-08 02:59:15 UTC (rev 4171)
@@ -20,6 +20,8 @@
 #endif
 #define unless(p)       if (not (p))
 #define until(p)        while (not (p))
+#define cardof(a)       (sizeof(a) / sizeof(*(a)))
+#define endof(a)        ((a) + cardof(a))
 
 #define TWOPOWER(n) (1 << (n))