[MLton-commit] r4324

Matthew Fluet MLton@mlton.org
Sat, 28 Jan 2006 09:55:02 -0800


Starting re-integration of generated ML-side basis library imports.


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

A   mlton/branches/on-20050822-x86_64-branch/basis-library/config/
A   mlton/branches/on-20050822-x86_64-branch/basis-library/config/c/
A   mlton/branches/on-20050822-x86_64-branch/basis-library/config/c/amd64-linux/
A   mlton/branches/on-20050822-x86_64-branch/basis-library/config/c/amd64-linux/c-types.sml
U   mlton/branches/on-20050822-x86_64-branch/basis-library/integer/integer.sig
U   mlton/branches/on-20050822-x86_64-branch/basis-library/integer/word.sig
U   mlton/branches/on-20050822-x86_64-branch/basis-library/libs/basis-extra/basis-extra.mlb
D   mlton/branches/on-20050822-x86_64-branch/basis-library/libs/primitive.mlb
D   mlton/branches/on-20050822-x86_64-branch/basis-library/misc/primitive.sml
U   mlton/branches/on-20050822-x86_64-branch/basis-library/mlton/ffi.sig
U   mlton/branches/on-20050822-x86_64-branch/basis-library/mlton/rusage.sml
D   mlton/branches/on-20050822-x86_64-branch/basis-library/posix/primitive.sml
A   mlton/branches/on-20050822-x86_64-branch/basis-library/primitive/
A   mlton/branches/on-20050822-x86_64-branch/basis-library/primitive/posix-primitive.sml
A   mlton/branches/on-20050822-x86_64-branch/basis-library/primitive/prim-basis.mlb
A   mlton/branches/on-20050822-x86_64-branch/basis-library/primitive/prim-basis.sml
A   mlton/branches/on-20050822-x86_64-branch/basis-library/primitive/primitive.mlb
A   mlton/branches/on-20050822-x86_64-branch/basis-library/primitive/primitive.sml
U   mlton/branches/on-20050822-x86_64-branch/basis-library/real/pack-real.sml
U   mlton/branches/on-20050822-x86_64-branch/basis-library/system/date.sml
U   mlton/branches/on-20050822-x86_64-branch/runtime/basis/MLton/Rusage/rusage.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/gen/basis-ffi.def

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

Added: mlton/branches/on-20050822-x86_64-branch/basis-library/config/c/amd64-linux/c-types.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library/config/c/amd64-linux/c-types.sml	2006-01-28 17:09:17 UTC (rev 4323)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/config/c/amd64-linux/c-types.sml	2006-01-28 17:54:57 UTC (rev 4324)
@@ -0,0 +1,78 @@
+(* Copyright (C) 2004-2006 Henry Cejtin, Matthew Fluet, Suresh
+ *    Jagannathan, and Stephen Weeks.
+ *
+ * MLton is released under a BSD-style license.
+ * See the file MLton-LICENSE for details.
+ *)
+
+structure C = struct
+
+
+(* C *)
+structure Char = Int8
+structure SChar = Int8
+structure UChar = Word8
+structure Short = Int16
+structure SShort = Int16
+structure UShort = Word16
+structure Int = Int32
+structure SInt = Int32
+structure UInt = Word32
+structure Long = Int32
+structure SLong = Int32
+structure ULong = Word32
+structure LongLong = Int64
+structure SLongLong = Int64
+structure ULongLong = Word64
+structure Float = Real32
+structure Double = Real64
+structure Size = Word32
+
+structure String = Word32
+structure StringArray = Word32
+
+(* Generic integers *)
+structure Fd = Int
+structure Signal = Int
+structure Status = Int
+structure Sock = Int
+
+(* from <dirent.h> *)
+structure DirP = Word32
+
+(* from <poll.h> *)
+structure NFds = Word32
+
+(* from <resource.h> *)
+structure RLim = Word64
+
+(* from <sys/types.h> *)
+structure Clock = Int32
+structure Dev = Word64
+structure GId = Word32
+structure Id = Word32
+structure INo = Word64
+structure Mode = Word32
+structure NLink = Word32
+structure Off = Int64
+structure PId = Int32
+structure SSize = Int32
+structure SUSeconds = Int32
+structure Time = Int32
+structure UId = Word32
+structure USeconds = Word32
+
+(* from <sys/socket.h> *)
+structure Socklen = Word32
+
+(* from <termios.h> *)
+structure CC = Word8
+structure Speed = Word32
+structure TCFlag = Word32
+
+(* from "gmp.h" *)
+structure MPLimb = Word32
+
+
+structure Errno = struct type 'a t = 'a end
+end

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library/integer/integer.sig
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library/integer/integer.sig	2006-01-28 17:09:17 UTC (rev 4323)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/integer/integer.sig	2006-01-28 17:54:57 UTC (rev 4324)
@@ -5,7 +5,7 @@
 
 structure LargeInt =
    struct
-      type int = intInf
+      type int = Primitive.IntInf.int
    end
 
 signature INTEGER_GLOBAL =

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library/integer/word.sig
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library/integer/word.sig	2006-01-28 17:09:17 UTC (rev 4323)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/integer/word.sig	2006-01-28 17:54:57 UTC (rev 4324)
@@ -5,7 +5,7 @@
 
 structure LargeWord = 
    struct
-      type word = word64
+      type word = Primitive.Word64.word
    end
 
 signature WORD_GLOBAL =

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library/libs/basis-extra/basis-extra.mlb
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library/libs/basis-extra/basis-extra.mlb	2006-01-28 17:09:17 UTC (rev 4323)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/libs/basis-extra/basis-extra.mlb	2006-01-28 17:54:57 UTC (rev 4324)
@@ -12,7 +12,7 @@
    "warnUnused true" "forceUsed"
 in
    local
-      ../primitive.mlb
+      ../../primitive/primitive.mlb
       (* Common basis implementation. *)
       ../../top-level/infixes.sml
       ../../misc/basic.sml

Deleted: mlton/branches/on-20050822-x86_64-branch/basis-library/libs/primitive.mlb
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library/libs/primitive.mlb	2006-01-28 17:09:17 UTC (rev 4323)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/libs/primitive.mlb	2006-01-28 17:54:57 UTC (rev 4324)
@@ -1,22 +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.
- *)
-
-ann 
-   "allowConstant true"
-   "allowFFI true"
-   "allowPrim true"
-   "allowRebindEquals true"
-   "deadCode true"
-   "nonexhaustiveMatch warn"
-   "redundantMatch warn"
-   "sequenceNonUnit warn"
-   "warnUnused true"
-in
-   _prim
-   ../misc/primitive.sml
-   ../posix/primitive.sml
-end

Deleted: mlton/branches/on-20050822-x86_64-branch/basis-library/misc/primitive.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library/misc/primitive.sml	2006-01-28 17:09:17 UTC (rev 4323)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/misc/primitive.sml	2006-01-28 17:54:57 UTC (rev 4324)
@@ -1,2271 +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.
- *)
-
-(* Primitive names are special -- see atoms/prim.fun. *)
-
-infix 4 = (* <> > >= < <= *)
-
-val op = = fn z => _prim "MLton_equal": ''a * ''a -> bool; z
-
-structure Array =
-   struct
-      type 'a array = 'a array
-   end
-
-type 'a array = 'a Array.array
-
-structure Bool =
-   struct
-      datatype bool = datatype bool
-      type t = bool
-   end
-
-structure Char =
-   struct
-      type t = char8
-      type char = t
-   end
-type char = Char.char
-structure Char2 =
-   struct
-      type t = char16
-      type char = t
-   end
-structure Char4 =
-   struct
-      type t = char32
-      type char = t
-   end
-
-type exn = exn
-
-structure Int8 =
-   struct
-      type t = int8
-      type int = t
-   end
-structure Int16 =
-   struct
-      type t = int16
-      type int = t
-   end
-structure Int32 =
-   struct
-      type t = int32
-      type int = t
-   end
-structure Int = Int32
-type int = Int.int
-structure Int64 =
-   struct
-      type t = int64
-      type int = t
-   end
-structure Position = Int64
-structure IntInf =
-   struct
-      type t = intInf
-      type int = t
-   end
-(*structure LargeInt = IntInf*)
-
-structure Real32 =
-   struct
-      type t = real32
-      type real = t
-   end
-structure Real64 =
-   struct
-      type t = real64
-      type real = t
-   end
-structure Real = Real64
-type real = Real.real
-
-structure String =
-   struct
-      type t = char vector
-      type string = t
-   end
-type string = String.string
-structure String2 =
-   struct
-      type t = Char2.t vector
-      type string = t
-   end
-structure String4 =
-   struct
-      type t = Char4.t vector
-      type string = t
-   end
-
-structure PreThread :> sig type t end = struct type t = thread end
-structure Thread :> sig type t end = struct type t = thread end
-
-structure Word8 =
-   struct
-      type t = word8
-      type word = t
-   end
-structure Word16 =
-   struct
-      type t = word16
-      type word = t
-   end
-structure Word32 =
-   struct
-      type t = word32
-      type word = t
-   end
-structure Word = Word32
-type word = Word.word
-structure Word64 =
-   struct
-      type t = word64
-      type word = t
-   end
-structure LargeWord = Word64
-
-type 'a vector = 'a vector
-type 'a weak = 'a weak
-
-(* NullString is used for strings that must be passed to C and hence must be
- * null terminated.  After the Primitive structure is defined,
- * NullString.fromString is replaced by a version that checks that the string
- * is indeed null terminated.  See the bottom of this file.
- *)
-structure NullString :>
-   sig
-      type t
-
-      val fromString: string -> t
-   end =
-   struct
-      type t = string
-
-      val fromString = fn s => s
-   end
-
-structure Pointer =
-   struct
-      type t = pointer
-   end
-
-structure GetSet =
-   struct
-      type 'a t = (unit -> 'a) * ('a -> unit)
-   end
-
-structure Pid :> sig
-                    eqtype t
-
-                    val fromInt: int -> t
-                    val toInt: t -> int
-                 end =
-   struct
-      type t = int
-
-      val fromInt = fn i => i
-      val toInt = fn i => i
-      val _ = fromInt
-   end
-   
-exception Fail of string
-exception Match = Match
-exception PrimitiveOverflow = Overflow
-exception Overflow
-exception Size
-
-val wrapOverflow: ('a -> 'b) -> ('a -> 'b) =
-   fn f => fn a => f a handle PrimitiveOverflow => raise Overflow
-
-datatype 'a option = NONE | SOME of 'a
-
-fun not b = if b then false else true
-   
-functor Comparisons (type t
-                     val < : t * t -> bool) =
-   struct
-      fun <= (a, b) = not (< (b, a))
-      fun > (a, b) = < (b, a)
-      fun >= (a, b) = <= (b, a)
-   end
-
-functor RealComparisons (type t
-                         val < : t * t -> bool
-                         val <= : t * t -> bool) =
-   struct
-      fun > (a, b) = < (b, a)
-      fun >= (a, b) = <= (b, a)
-   end
-
-structure Primitive =
-   struct
-      val bug = _import "MLton_bug": NullString.t -> unit;
-      val debug = _command_line_const "MLton.debug": bool = false;
-      val detectOverflow =
-         _command_line_const "MLton.detectOverflow": bool = true;
-      val eq = _prim "MLton_eq": 'a * 'a -> bool;
-      val installSignalHandler =
-         _prim "MLton_installSignalHandler": unit -> unit;
-      val safe = _command_line_const "MLton.safe": bool = true;
-      val touch = _prim "MLton_touch": 'a -> unit;
-      val usesCallcc: bool ref = ref false;
-
-      structure Stdio =
-         struct
-            val print = _import "Stdio_print": string -> unit;
-         end
-
-      structure Array =
-         struct
-            val array0Const = _prim "Array_array0Const": unit -> 'a array;
-            val length = _prim "Array_length": 'a array -> int;
-            (* There is no maximum length on arrays, so maxLen = maxInt. *)
-            val maxLen: int = 0x7FFFFFFF
-            val sub = _prim "Array_sub": 'a array * int -> 'a;
-            val update = _prim "Array_update": 'a array * int * 'a -> unit;
-         end
-
-      structure CString =
-         struct
-            type t = Pointer.t
-         end
-      structure CStringArray =
-         struct
-            type t = Pointer.t
-         end
-
-      structure GCState =
-         struct
-            type t = Pointer.t
-
-            val gcState = #1 _symbol "gcStateAddress": t GetSet.t; ()
-         end
-      
-      structure CallStack =
-         struct
-            (* The most recent caller is at index 0 in the array. *)
-            datatype t = T of int array
-
-            val callStack =
-               _import "GC_callStack": GCState.t * int array -> unit;
-            val frameIndexSourceSeq =
-               _import "GC_frameIndexSourceSeq": GCState.t * int -> Pointer.t;
-            val keep = _command_line_const "CallStack.keep": bool = false;
-            val numStackFrames =
-               _import "GC_numStackFrames": GCState.t -> int;
-            val sourceName = _import "GC_sourceName": GCState.t * int -> CString.t;
-         end
-
-      structure Char =
-         struct
-            open Char
-               
-            val op < = _prim "WordU8_lt": char * char -> bool;
-            val chr = _prim "WordS32_toWord8": int -> char;
-            val ord = _prim "WordU8_toWord32": char -> int;
-            val toInt8 = _prim "WordS8_toWord8": char -> Int8.int;
-            val fromInt8 = _prim "WordS8_toWord8": Int8.int -> char;
-            val toWord8 = _prim "WordU8_toWord8": char -> Word8.word;
-            val fromWord8 = _prim "WordU8_toWord8": Word8.word -> char;
-         end
-
-      structure Char =
-         struct
-            open Char
-            local
-               structure S = Comparisons (Char)
-            in
-               open S
-            end
-         end
-
-      structure Char2 =
-         struct
-            open Char2
-
-            val op < = _prim "WordU16_lt": char * char -> bool;
-            val chr = _prim "WordS32_toWord16": int -> char;
-            val ord = _prim "WordU16_toWord32": char -> int;
-            val toInt16 = _prim "WordS16_toWord16": char -> Int16.int;
-            val fromInt16 = _prim "WordS16_toWord16": Int16.int -> char;
-            (* val toWord16 = _prim "WordU16_toWord16": char -> Word16.word; *)
-            (* val fromWord16 = _prim "WordU16_toWord16": Word16.word -> char; *)
-         end
-      
-      structure Char4 =
-         struct
-            open Char4
-
-            val op < = _prim "WordU32_lt": char * char -> bool;
-            val chr = _prim "WordS32_toWord32": int -> char;
-            val ord = _prim "WordU32_toWord32": char -> int;
-            val toInt32 = _prim "WordS32_toWord32": char -> Int32.int;
-            val fromInt32 = _prim "WordS32_toWord32": Int32.int -> char;
-            (* val toWord32 = _prim "WordU32_toWord32": char -> Word32.word; *)
-            (* val fromWord32 = _prim "WordU32_toWord32": Word32.word -> char; *)
-         end
-
-      structure CommandLine =
-         struct
-            val argc = #1 _symbol "CommandLine_argc": int GetSet.t;
-            val argv = #1 _symbol "CommandLine_argv": CStringArray.t GetSet.t;
-            val commandName = #1 _symbol "CommandLine_commandName": CString.t GetSet.t;
-         end
-
-      structure Date =
-         struct
-            type time = int
-            type size = int
-
-            structure Tm =
-               struct
-                  val sec = _import "Date_Tm_sec": unit -> int;
-                  val min = _import "Date_Tm_min": unit -> int;
-                  val hour = _import "Date_Tm_hour": unit -> int;
-                  val mday = _import "Date_Tm_mday": unit -> int;
-                  val mon = _import "Date_Tm_mon": unit -> int;
-                  val year = _import "Date_Tm_year": unit -> int;
-                  val wday = _import "Date_Tm_wday": unit -> int;
-                  val yday = _import "Date_Tm_yday": unit -> int;
-                  val isdst = _import "Date_Tm_isdst": unit -> int;
-
-                  val setSec = _import "Date_Tm_setSec": int -> unit;
-                  val setMin = _import "Date_Tm_setMin": int -> unit;
-                  val setHour = _import "Date_Tm_setHour": int -> unit;
-                  val setMday = _import "Date_Tm_setMday": int -> unit;
-                  val setMon = _import "Date_Tm_setMon": int -> unit;
-                  val setYear = _import "Date_Tm_setYear": int -> unit;
-                  val setWday = _import "Date_Tm_setWday": int -> unit;
-                  val setYday = _import "Date_Tm_setYday": int -> unit;
-                  val setIsdst = _import "Date_Tm_setIsdst": int -> unit;
-               end
-               
-            val gmTime = _import "Date_gmTime": time ref -> unit;
-            val localOffset = _import "Date_localOffset": unit -> int;
-            val localTime = _import "Date_localTime": time ref -> unit;
-            val mkTime = _import "Date_mkTime": unit -> time;
-            val strfTime =
-               _import "Date_strfTime": char array * size * NullString.t -> size;
-         end
-    
-      structure Exn =
-         struct
-            (* The polymorphism with extra and setInitExtra is because primitives
-             * are only supposed to deal with basic types.  The polymorphism
-             * allows the various passes like monomorphisation to translate
-             * the types appropriately.
-             *)
-            type extra = CallStack.t option
-
-            val extra = _prim "Exn_extra": exn -> 'a;
-            val extra: exn -> extra = extra
-            val name = _prim "Exn_name": exn -> string;
-            val keepHistory =
-               _command_line_const "Exn.keepHistory": bool = false;
-            val setExtendExtra = _prim "Exn_setExtendExtra": ('a -> 'a) -> unit;
-            val setExtendExtra: (extra -> extra) -> unit = setExtendExtra
-            val setInitExtra = _prim "Exn_setInitExtra": 'a -> unit;
-            val setInitExtra: extra -> unit = setInitExtra
-         end
-
-      structure FFI =
-         struct
-            val getOp = #1 _symbol "MLton_FFI_op": int GetSet.t;
-            val int8Array = #1 _symbol "MLton_FFI_Int8": Pointer.t GetSet.t; ()
-            val int16Array = #1 _symbol "MLton_FFI_Int16": Pointer.t GetSet.t; ()
-            val int32Array = #1 _symbol "MLton_FFI_Int32": Pointer.t GetSet.t; ()
-            val int64Array = #1 _symbol "MLton_FFI_Int64": Pointer.t GetSet.t; ()
-            val numExports = _build_const "MLton_FFI_numExports": int;
-            val pointerArray = #1 _symbol "MLton_FFI_Pointer": Pointer.t GetSet.t; ()
-            val real32Array = #1 _symbol "MLton_FFI_Real32": Pointer.t GetSet.t; ()
-            val real64Array = #1 _symbol "MLton_FFI_Real64": Pointer.t GetSet.t; ()
-            val word8Array = #1 _symbol "MLton_FFI_Word8": Pointer.t GetSet.t; ()
-            val word16Array = #1 _symbol "MLton_FFI_Word16": Pointer.t GetSet.t; ()
-            val word32Array = #1 _symbol "MLton_FFI_Word32": Pointer.t GetSet.t; ()
-            val word64Array = #1 _symbol "MLton_FFI_Word64": Pointer.t GetSet.t; ()
-         end
-
-      structure GC =
-         struct
-            val collect = _prim "GC_collect": unit -> unit;
-            val pack = _import "GC_pack": GCState.t -> unit;
-            val setHashConsDuringGC =
-               _import "GC_setHashConsDuringGC": GCState.t * bool -> unit;
-            val setMessages = 
-               _import "GC_setMessages": GCState.t * bool -> unit;
-            val setRusageMeasureGC = 
-               _import "GC_setRusageMeasureGC": GCState.t * bool -> unit;
-            val setSummary = 
-               _import "GC_setSummary": GCState.t * bool -> unit;
-            val unpack = 
-               _import "GC_unpack": GCState.t -> unit;
-         end
-      
-      structure IEEEReal =
-         struct
-            structure RoundingMode =
-               struct
-                  type t = int
-                     
-                  val toNearest = _const "FE_TONEAREST": t;
-                  val downward = _const "FE_DOWNWARD": t;
-                  val noSupport = _const "FE_NOSUPPORT": t;
-                  val upward = _const "FE_UPWARD": t;
-                  val towardZero = _const "FE_TOWARDZERO": t;
-               end
-            
-            val getRoundingMode =
-               _import "IEEEReal_getRoundingMode": unit -> int;
-            val setRoundingMode =
-               _import "IEEEReal_setRoundingMode": int -> unit;
-         end
-
-      structure Int1 =
-         struct
-            type big = Int8.int
-            type int = int1
-            val fromBigUnsafe = _prim "WordU8_toWord1": big -> int;
-            val precision' = 1
-            val toBig = _prim "WordU1_toWord8": int -> big;
-         end
-      structure Int2 =
-         struct
-            type big = Int8.int
-            type int = int2
-            val fromBigUnsafe = _prim "WordU8_toWord2": big -> int;
-            val precision' = 2
-            val toBig = _prim "WordU2_toWord8": int -> big;
-         end
-      structure Int3 =
-         struct
-            type big = Int8.int
-            type int = int3
-            val fromBigUnsafe = _prim "WordU8_toWord3": big -> int;
-            val precision' = 3
-            val toBig = _prim "WordU3_toWord8": int -> big;
-         end
-      structure Int4 =
-         struct
-            type big = Int8.int
-            type int = int4
-            val fromBigUnsafe = _prim "WordU8_toWord4": big -> int;
-            val precision' = 4
-            val toBig = _prim "WordU4_toWord8": int -> big;
-         end
-      structure Int5 =
-         struct
-            type big = Int8.int
-            type int = int5
-            val fromBigUnsafe = _prim "WordU8_toWord5": big -> int;
-            val precision' = 5
-            val toBig = _prim "WordU5_toWord8": int -> big;
-         end
-      structure Int6 =
-         struct
-            type big = Int8.int
-            type int = int6
-            val fromBigUnsafe = _prim "WordU8_toWord6": big -> int;
-            val precision' = 6
-            val toBig = _prim "WordU6_toWord8": int -> big;
-         end
-      structure Int7 =
-         struct
-            type big = Int8.int
-            type int = int7
-            val fromBigUnsafe = _prim "WordU8_toWord7": big -> int;
-            val precision' = 7
-            val toBig = _prim "WordU7_toWord8": int -> big;
-         end
-      structure Int8 =
-         struct
-            type t = Int8.int
-            type int = t
-               
-            val precision' : Int.int = 8
-            val maxInt' : int = 0x7f
-            val minInt' : int = ~0x80
-
-            val *? = _prim "WordS8_mul": int * int -> int;
-            val * =
-               if detectOverflow
-                  then wrapOverflow (_prim "WordS8_mulCheck": int * int -> int;)
-               else *?
-            val +? = _prim "Word8_add": int * int -> int;
-            val + =
-               if detectOverflow
-                  then wrapOverflow (_prim "WordS8_addCheck": int * int -> int;)
-               else +?
-            val -? = _prim "Word8_sub": int * int -> int;
-            val - =
-               if detectOverflow
-                  then wrapOverflow (_prim "WordS8_subCheck": int * int -> int;)
-               else -?
-            val op < = _prim "WordS8_lt": int * int -> bool;
-            val quot = _prim "WordS8_quot": int * int -> int;
-            val rem = _prim "WordS8_rem": int * int -> int;
-            val << = _prim "Word8_lshift": int * Word.word -> int;
-            val >> = _prim "WordU8_rshift": int * Word.word -> int;
-            val ~>> = _prim "WordS8_rshift": int * Word.word -> int;
-            val ~? = _prim "Word8_neg": int -> int; 
-            val ~ =
-               if detectOverflow
-                  then wrapOverflow (_prim "Word8_negCheck": int -> int;)
-               else ~?
-            val andb = _prim "Word8_andb": int * int -> int;
-            val fromInt = _prim "WordS32_toWord8": Int.int -> int;
-            val toInt = _prim "WordS8_toWord32": int -> Int.int;
-         end
-      structure Int8 =
-         struct
-            open Int8
-            local
-               structure S = Comparisons (Int8)
-            in
-               open S
-            end
-         end
-      structure Int9 =
-         struct
-            type big = Int16.int
-            type int = int9
-            val fromBigUnsafe = _prim "WordU16_toWord9": big -> int;
-            val precision' = 9
-            val toBig = _prim "WordU9_toWord16": int -> big;
-         end
-      structure Int10 =
-         struct
-            type big = Int16.int
-            type int = int10
-            val fromBigUnsafe = _prim "WordU16_toWord10": big -> int;
-            val precision' = 10
-            val toBig = _prim "WordU10_toWord16": int -> big;
-         end
-      structure Int11 =
-         struct
-            type big = Int16.int
-            type int = int11
-            val fromBigUnsafe = _prim "WordU16_toWord11": big -> int;
-            val precision' = 11
-            val toBig = _prim "WordU11_toWord16": int -> big;
-         end
-      structure Int12 =
-         struct
-            type big = Int16.int
-            type int = int12
-            val fromBigUnsafe = _prim "WordU16_toWord12": big -> int;
-            val precision' = 12
-            val toBig = _prim "WordU12_toWord16": int -> big;
-         end
-      structure Int13 =
-         struct
-            type big = Int16.int
-            type int = int13
-            val fromBigUnsafe = _prim "WordU16_toWord13": big -> int;
-            val precision' = 13
-            val toBig = _prim "WordU13_toWord16": int -> big;
-         end
-      structure Int14 =
-         struct
-            type big = Int16.int
-            type int = int14
-            val fromBigUnsafe = _prim "WordU16_toWord14": big -> int;
-            val precision' = 14
-            val toBig = _prim "WordU14_toWord16": int -> big;
-         end
-      structure Int15 =
-         struct
-            type big = Int16.int
-            type int = int15
-            val fromBigUnsafe = _prim "WordU16_toWord15": big -> int;
-            val precision' = 15
-            val toBig = _prim "WordU15_toWord16": int -> big;
-         end    
-      structure Int16 =
-         struct
-            type t = Int16.int
-            type int = t
-               
-            val precision' : Int.int = 16
-            val maxInt' : int = 0x7fff
-            val minInt' : int = ~0x8000
-
-            val *? = _prim "WordS16_mul": int * int -> int;
-            val * =
-               if detectOverflow
-                  then (wrapOverflow
-                        (_prim "WordS16_mulCheck": int * int -> int;))
-               else *?
-            val +? = _prim "Word16_add": int * int -> int;
-            val + =
-               if detectOverflow
-                  then (wrapOverflow
-                        (_prim "WordS16_addCheck": int * int -> int;))
-               else +?
-            val -? = _prim "Word16_sub": int * int -> int;
-            val - =
-               if detectOverflow
-                  then (wrapOverflow
-                        (_prim "WordS16_subCheck": int * int -> int;))
-               else -?
-            val op < = _prim "WordS16_lt": int * int -> bool;
-            val quot = _prim "WordS16_quot": int * int -> int;
-            val rem = _prim "WordS16_rem": int * int -> int;
-            val << = _prim "Word16_lshift": int * Word.word -> int;
-            val >> = _prim "WordU16_rshift": int * Word.word -> int;
-            val ~>> = _prim "WordS16_rshift": int * Word.word -> int;
-            val ~? = _prim "Word16_neg": int -> int; 
-            val ~ =
-               if detectOverflow
-                  then wrapOverflow (_prim "Word16_negCheck": int -> int;)
-               else ~?
-            val andb = _prim "Word16_andb": int * int -> int;
-            val fromInt = _prim "WordS32_toWord16": Int.int -> int;
-            val toInt = _prim "WordS16_toWord32": int -> Int.int;
-         end
-      structure Int16 =
-         struct
-            open Int16
-            local
-               structure S = Comparisons (Int16)
-            in
-               open S
-            end
-         end
-      structure Int17 =
-         struct
-            type big = Int32.int
-            type int = int17
-            val fromBigUnsafe = _prim "WordU32_toWord17": big -> int;
-            val precision' = 17
-            val toBig = _prim "WordU17_toWord32": int -> big;
-         end
-      structure Int18 =
-         struct
-            type big = Int32.int
-            type int = int18
-            val fromBigUnsafe = _prim "WordU32_toWord18": big -> int;
-            val precision' = 18
-            val toBig = _prim "WordU18_toWord32": int -> big;
-         end
-      structure Int19 =
-         struct
-            type big = Int32.int
-            type int = int19
-            val fromBigUnsafe = _prim "WordU32_toWord19": big -> int;
-            val precision' = 19
-            val toBig = _prim "WordU19_toWord32": int -> big;
-         end
-      structure Int20 =
-         struct
-            type big = Int32.int
-            type int = int20
-            val fromBigUnsafe = _prim "WordU32_toWord20": big -> int;
-            val precision' = 20
-            val toBig = _prim "WordU20_toWord32": int -> big;
-         end
-      structure Int21 =
-         struct
-            type big = Int32.int
-            type int = int21
-            val fromBigUnsafe = _prim "WordU32_toWord21": big -> int;
-            val precision' = 21
-            val toBig = _prim "WordU21_toWord32": int -> big;
-         end
-      structure Int22 =
-         struct
-            type big = Int32.int
-            type int = int22
-            val fromBigUnsafe = _prim "WordU32_toWord22": big -> int;
-            val precision' = 22
-            val toBig = _prim "WordU22_toWord32": int -> big;
-         end
-      structure Int23 =
-         struct
-            type big = Int32.int
-            type int = int23
-            val fromBigUnsafe = _prim "WordU32_toWord23": big -> int;
-            val precision' = 23
-            val toBig = _prim "WordU23_toWord32": int -> big;
-         end
-      structure Int24 =
-         struct
-            type big = Int32.int
-            type int = int24
-            val fromBigUnsafe = _prim "WordU32_toWord24": big -> int;
-            val precision' = 24
-            val toBig = _prim "WordU24_toWord32": int -> big;
-         end
-      structure Int25 =
-         struct
-            type big = Int32.int
-            type int = int25
-            val fromBigUnsafe = _prim "WordU32_toWord25": big -> int;
-            val precision' = 25
-            val toBig = _prim "WordU25_toWord32": int -> big;
-         end
-      structure Int26 =
-         struct
-            type big = Int32.int
-            type int = int26
-            val fromBigUnsafe = _prim "WordU32_toWord26": big -> int;
-            val precision' = 26
-            val toBig = _prim "WordU26_toWord32": int -> big;
-         end
-      structure Int27 =
-         struct
-            type big = Int32.int
-            type int = int27
-            val fromBigUnsafe = _prim "WordU32_toWord27": big -> int;
-            val precision' = 27
-            val toBig = _prim "WordU27_toWord32": int -> big;
-         end
-      structure Int28 =
-         struct
-            type big = Int32.int
-            type int = int28
-            val fromBigUnsafe = _prim "WordU32_toWord28": big -> int;
-            val precision' = 28
-            val toBig = _prim "WordU28_toWord32": int -> big;
-         end
-      structure Int29 =
-         struct
-            type big = Int32.int
-            type int = int29
-            val fromBigUnsafe = _prim "WordU32_toWord29": big -> int;
-            val precision' = 29
-            val toBig = _prim "WordU29_toWord32": int -> big;
-         end
-      structure Int30 =
-         struct
-            type big = Int32.int
-            type int = int30
-            val fromBigUnsafe = _prim "WordU32_toWord30": big -> int;
-            val precision' = 30
-            val toBig = _prim "WordU30_toWord32": int -> big;
-         end
-      structure Int31 =
-         struct
-            type big = Int32.int
-            type int = int31
-            val fromBigUnsafe = _prim "WordU32_toWord31": big -> int;
-            val precision' = 31
-            val toBig = _prim "WordU31_toWord32": int -> big;
-         end
-      structure Int32 =
-         struct
-            type t = Int32.int
-            type int = t
-
-            val precision' : Int.int = 32
-            val maxInt' : int = 0x7fffffff
-            val minInt' : int = ~0x80000000
-
-            val *? = _prim "WordS32_mul": int * int -> int;
-            val * =
-               if detectOverflow
-                  then (wrapOverflow
-                        (_prim "WordS32_mulCheck": int * int -> int;))
-               else *?
-            val +? = _prim "Word32_add": int * int -> int;
-            val + =
-               if detectOverflow
-                  then (wrapOverflow
-                        (_prim "WordS32_addCheck": int * int -> int;))
-               else +?
-            val -? = _prim "Word32_sub": int * int -> int;
-            val - =
-               if detectOverflow
-                  then (wrapOverflow
-                        (_prim "WordS32_subCheck": int * int -> int;))
-               else -?
-            val op < = _prim "WordS32_lt": int * int -> bool;
-            val quot = _prim "WordS32_quot": int * int -> int;
-            val rem = _prim "WordS32_rem": int * int -> int;
-            val << = _prim "Word32_lshift": int * Word.word -> int;
-            val >> = _prim "WordU32_rshift": int * Word.word -> int;
-            val ~>> = _prim "WordS32_rshift": int * Word.word -> int;
-            val ~? = _prim "Word32_neg": int -> int; 
-            val ~ =
-               if detectOverflow
-                  then wrapOverflow (_prim "Word32_negCheck": int -> int;)
-               else ~?
-            val andb = _prim "Word32_andb": int * int -> int;
-            val fromInt : int -> int = fn x => x
-            val toInt : int -> int = fn x => x
-         end
-      structure Int32 =
-         struct
-            open Int32
-            local
-               structure S = Comparisons (Int32)
-            in
-               open S
-            end
-         end
-      structure Int = Int32
-      structure Int64 =
-         struct
-            type t = Int64.int
-            type int = t
-
-            val precision' : Int.int = 64
-            val maxInt' : int = 0x7FFFFFFFFFFFFFFF
-            val minInt' : int = ~0x8000000000000000
-
-            val *? = _prim "WordS64_mul": int * int -> int;
-            val * = fn _ => raise Fail "Int64.* unimplemented"
-(*
-            val * =
-               if detectOverflow
-                  then _prim "WordS64_mulCheck": int * int -> int;
-               else *?
-*)
-            val +? = _prim "Word64_add": int * int -> int;
-            val + =
-               if detectOverflow
-                  then (wrapOverflow
-                        (_prim "WordS64_addCheck": int * int -> int;))
-               else +?
-            val -? = _prim "Word64_sub": int * int -> int;
-            val - =
-               if detectOverflow
-                  then (wrapOverflow
-                        (_prim "WordS64_subCheck": int * int -> int;))
-               else -?
-            val op < = _prim "WordS64_lt": int * int -> bool;
-            val << = _prim "Word64_lshift": int * Word.word -> int;
-            val >> = _prim "WordU64_rshift": int * Word.word -> int;
-            val ~>> = _prim "WordS64_rshift": int * Word.word -> int;
-            val quot = _prim "WordS64_quot": int * int -> int;
-            val rem = _prim "WordS64_rem": int * int -> int;
-            val ~? = _prim "Word64_neg": int -> int; 
-            val ~ =
-               if detectOverflow
-                  then wrapOverflow (_prim "Word64_negCheck": int -> int;)
-               else ~?
-            val andb = _prim "Word64_andb": int * int -> int;
-            val fromInt = _prim "WordS32_toWord64": Int.int -> int;
-            val fromWord = _prim "WordU32_toWord64": word -> int;
-            val toInt = _prim "WordU64_toWord32": int -> Int.int;
-            val toWord = _prim "WordU64_toWord32": int -> word;
-         end
-      structure Int64 =
-         struct
-            open Int64
-            local
-               structure S = Comparisons (Int64)
-            in
-               open S
-            end
-         end
-
-      structure Array =
-         struct
-            open Array
-
-            val array = _prim "Array_array": int -> 'a array;
-            val array =
-               fn n => if safe andalso Int.< (n, 0)
-                          then raise Size
-                       else array n
-         end
-
-      structure IntInf =
-         struct
-            open IntInf
-
-            val + = _prim "IntInf_add": int * int * word -> int;
-            val andb = _prim "IntInf_andb": int * int * word -> int;
-            val ~>> = _prim "IntInf_arshift": int * word * word -> int;
-            val compare = _prim "IntInf_compare": int * int -> Int.int;
-            val fromVector = _prim "WordVector_toIntInf": word vector -> int;
-            val fromWord = _prim "Word_toIntInf": word -> int;
-            val gcd = _prim "IntInf_gcd": int * int * word -> int;
-            val << = _prim "IntInf_lshift": int * word * word -> int;
-            val * = _prim "IntInf_mul": int * int * word -> int;
-            val ~ = _prim "IntInf_neg": int * word -> int;
-            val notb = _prim "IntInf_notb": int * word -> int;
-            val orb = _prim "IntInf_orb": int * int * word -> int;
-            val quot = _prim "IntInf_quot": int * int * word -> int;
-            val rem = _prim "IntInf_rem": int * int * word -> int;
-            val smallMul =
-               _import "IntInf_smallMul": word * word * word ref -> word;
-            val - = _prim "IntInf_sub": int * int * word -> int; 
-            val toString
-               = _prim "IntInf_toString": int * Int.int * word -> string;
-            val toVector = _prim "IntInf_toVector": int -> word vector;
-            val toWord = _prim "IntInf_toWord": int -> word;
-            val xorb = _prim "IntInf_xorb": int * int * word -> int;
-         end
-
-      structure Itimer =
-         struct
-            type which = int
-               
-            val prof = _const "Itimer_prof": which;
-            val real = _const "Itimer_real": which;
-            val set =
-               _import "Itimer_set": which * int * int * int * int -> unit;
-            val virtual = _const "Itimer_virtual": which;
-         end
-
-      structure MLton =
-         struct
-            structure Codegen =
-               struct
-                  datatype t = Bytecode | C | Native
-
-                  val codegen =
-                     case _build_const "MLton_Codegen_codegen": int; of
-                        0 => Bytecode
-                      | 1 => C
-                      | 2 => Native
-                      | _ => raise Fail "MLton_Codegen_codegen"
-
-                  val isBytecode = codegen = Bytecode
-                  (* val isC = codegen = C *)
-                  val isNative = codegen = Native
-               end
-            
-            (* val deserialize = _prim "MLton_deserialize": Word8Vector.vector -> 'a ref; *)
-            (* val serialize = _prim "MLton_serialize": 'a ref -> Word8Vector.vector; *)
-            val share = _prim "MLton_share": 'a -> unit;
-            val size = _prim "MLton_size": 'a ref -> int;
-
-            structure Platform =
-               struct
-                  structure Arch =
-                     struct
-                        datatype t = Alpha | AMD64 | ARM | HPPA | IA64 | m68k |
-                                     MIPS | PowerPC | S390 | Sparc | X86
-                        
-                        val host: t =
-                           case _const "MLton_Platform_Arch_host": string; of
-                              "alpha" => Alpha
-                            | "amd64" => AMD64
-                            | "arm" => ARM
-                            | "hppa" => HPPA
-                            | "ia64" => IA64
-                            | "m68k" => m68k
-                            | "mips" => MIPS
-                            | "powerpc" => PowerPC
-                            | "s390" => S390
-                            | "sparc" => Sparc
-                            | "x86" => X86
-                            | _ => raise Fail "strange MLton_Platform_Arch_host"
-
-                        val hostIsBigEndian =
-                           _const "MLton_Platform_Arch_bigendian": bool;
-                     end
-
-                  structure OS =
-                     struct
-                        datatype t =
-                           Cygwin
-                         | Darwin
-                         | FreeBSD
-                         | Linux
-                         | MinGW
-                         | NetBSD
-                         | OpenBSD
-                         | Solaris
-
-                        val host: t =
-                           case _const "MLton_Platform_OS_host": string; of
-                              "cygwin" => Cygwin
-                            | "darwin" => Darwin
-                            | "freebsd" => FreeBSD
-                            | "linux" => Linux
-                            | "mingw" => MinGW
-                            | "netbsd" => NetBSD
-                            | "openbsd" => OpenBSD
-                            | "solaris" => Solaris
-                            | _ => raise Fail "strange MLton_Platform_OS_host"
-
-                        val forkIsEnabled =
-                           case host of
-                              Cygwin =>
-                                 #1 _symbol "MLton_Platform_CygwinUseMmap": bool GetSet.t; ()
-                            | MinGW => false
-                            | _ => true
-
-                        val useWindowsProcess = not forkIsEnabled
-                     end
-               end
-
-            structure Process =
-               struct
-                  val spawne =
-                     if let
-                           open Platform.OS
-                        in
-                           case host of
-                              Cygwin => true
-                            | MinGW => true
-                            | _ => false
-                        end
-                        then
-                           _import "MLton_Process_spawne"
-                           : (NullString.t 
-                              * NullString.t array
-                              * NullString.t array
-                              -> Pid.t);
-                        else fn _ => raise Fail "spawne not defined"
-                  val spawnp =
-                     if let
-                           open Platform.OS
-                        in
-                           case host of
-                              Cygwin => true
-                            | MinGW => true
-                            | _ => false
-                        end
-                        then
-                           _import "MLton_Process_spawnp"
-                           : (NullString.t 
-                              * NullString.t array
-                              -> Pid.t);
-                        else fn _ => raise Fail "spawnp not defined"
-               end
-            
-            structure Profile =
-               struct
-                  val isOn = _build_const "MLton_Profile_isOn": bool;
-                  structure Data =
-                     struct
-                        type t = word
-
-                        val dummy:t = 0w0
-                        val free = 
-                           _import "GC_profileFree": GCState.t * t -> unit;
-                        val malloc = 
-                           _import "GC_profileMalloc": GCState.t -> t;
-                        val write = 
-                           _import "GC_profileWrite" 
-                           : GCState.t * t * word (* fd *) -> unit;
-                     end
-                  val done = _import "GC_profileDone": GCState.t -> unit;
-                  val getCurrent = 
-                     _import "GC_getProfileCurrent": GCState.t -> Data.t;
-                  val setCurrent =
-                     _import "GC_setProfileCurrent"
-                     : GCState.t * Data.t -> unit;
-               end
-            
-            structure Rlimit =
-               struct
-                  type rlim = word
-                     
-                  val infinity = _const "MLton_Rlimit_infinity": rlim;
-
-                  type t = int
-
-                  val cpuTime = _const "MLton_Rlimit_cpuTime": t;
-                  val coreFileSize = _const "MLton_Rlimit_coreFileSize": t;
-                  val dataSize = _const "MLton_Rlimit_dataSize": t;
-                  val fileSize = _const "MLton_Rlimit_fileSize": t;
-                  val lockedInMemorySize =
-                     _const "MLton_Rlimit_lockedInMemorySize": t;
-                  val numFiles = _const "MLton_Rlimit_numFiles": t;
-                  val numProcesses = _const "MLton_Rlimit_numProcesses": t;
-                  val residentSetSize = _const "MLton_Rlimit_residentSetSize": t;
-                  val stackSize = _const "MLton_Rlimit_stackSize": t;
-                  val virtualMemorySize =
-                     _const "MLton_Rlimit_virtualMemorySize": t;
-                     
-                  val get = _import "MLton_Rlimit_get": t -> int;
-                  val getHard = _import "MLton_Rlimit_getHard": unit -> rlim;
-                  val getSoft = _import "MLton_Rlimit_getSoft": unit -> rlim;
-                  val set = _import "MLton_Rlimit_set": t * rlim * rlim -> int;
-               end
-            
-            structure Rusage =
-               struct
-                 val ru = _import "MLton_Rusage_ru": GCState.t -> unit;
-                    
-                 val self_utime_sec = _import "MLton_Rusage_self_utime_sec": unit -> int;
-                 val self_utime_usec = _import "MLton_Rusage_self_utime_usec": unit -> int;
-                 val self_stime_sec = _import "MLton_Rusage_self_stime_sec": unit -> int;
-                 val self_stime_usec = _import "MLton_Rusage_self_stime_usec": unit -> int;
-                 val children_utime_sec = _import "MLton_Rusage_children_utime_sec": unit -> int;
-                 val children_utime_usec = _import "MLton_Rusage_children_utime_usec": unit -> int;
-                 val children_stime_sec = _import "MLton_Rusage_children_stime_sec": unit -> int;
-                 val children_stime_usec = _import "MLton_Rusage_children_stime_usec": unit -> int;
-                 val gc_utime_sec = _import "MLton_Rusage_gc_utime_sec": unit -> int;
-                 val gc_utime_usec = _import "MLton_Rusage_gc_utime_usec": unit -> int;
-                 val gc_stime_sec = _import "MLton_Rusage_gc_stime_sec": unit -> int;
-                 val gc_stime_usec = _import "MLton_Rusage_gc_stime_usec": unit -> int;
-               end
-
-            structure Syslog =
-               struct
-                  type openflag = int
-                     
-                  val CONS = _const "LOG_CONS": openflag;
-                  val NDELAY = _const "LOG_NDELAY": openflag;
-                  val PERROR = _const "LOG_PERROR": openflag;
-                  val PID = _const "LOG_PID": openflag;
-                     
-                  type facility = int
-                     
-                  val AUTHPRIV = _const "LOG_AUTHPRIV": facility;
-                  val CRON = _const "LOG_CRON": facility;
-                  val DAEMON = _const "LOG_DAEMON": facility;
-                  val KERN = _const "LOG_KERN": facility;
-                  val LOCAL0 = _const "LOG_LOCAL0": facility;
-                  val LOCAL1 = _const "LOG_LOCAL1": facility;
-                  val LOCAL2 = _const "LOG_LOCAL2": facility;
-                  val LOCAL3 = _const "LOG_LOCAL3": facility;
-                  val LOCAL4 = _const "LOG_LOCAL4": facility;
-                  val LOCAL5 = _const "LOG_LOCAL5": facility;
-                  val LOCAL6 = _const "LOG_LOCAL6": facility;
-                  val LOCAL7 = _const "LOG_LOCAL7": facility;
-                  val LPR = _const "LOG_LPR": facility;
-                  val MAIL = _const "LOG_MAIL": facility;
-                  val NEWS = _const "LOG_NEWS": facility;
-                  val SYSLOG = _const "LOG_SYSLOG": facility;
-                  val USER = _const "LOG_USER": facility;
-                  val UUCP = _const "LOG_UUCP": facility;
-                     
-                  type loglevel = int
-                     
-                  val EMERG = _const "LOG_EMERG": loglevel;
-                  val ALERT = _const "LOG_ALERT": loglevel;
-                  val CRIT = _const "LOG_CRIT": loglevel;
-                  val ERR = _const "LOG_ERR": loglevel;
-                  val WARNING = _const "LOG_WARNING": loglevel;
-                  val NOTICE = _const "LOG_NOTICE": loglevel;
-                  val INFO = _const "LOG_INFO": loglevel;
-                  val DEBUG = _const "LOG_DEBUG": loglevel;
-               end
-
-            structure Weak =
-               struct
-                  type 'a t = 'a weak
-                     
-                  val canGet = _prim "Weak_canGet": 'a t -> bool;
-                  val get = _prim "Weak_get": 'a t -> 'a;
-                  val new = _prim "Weak_new": 'a -> 'a t;
-               end
-         end
-
-      structure Net =
-         struct
-            (* val htonl = _import "Net_htonl": int -> int; *)
-            (* val ntohl = _import "Net_ntohl": int -> int; *)
-            val htons = _import "Net_htons": int -> int;
-            val ntohs = _import "Net_ntohs": int -> int;
-         end
-
-      structure NetHostDB =
-         struct
-            (* network byte order (MSB) *)
-            type pre_in_addr = word8 array
-            type in_addr = word8 vector
-            val inAddrLen = _const "NetHostDB_inAddrLen": int;
-            val INADDR_ANY = _const "NetHostDB_INADDR_ANY": int;
-            type addr_family = int
-            val entryName = _import "NetHostDB_Entry_name": unit -> CString.t;
-            val entryNumAliases = _import "NetHostDB_Entry_numAliases": unit -> int;
-            val entryAliasesN = _import "NetHostDB_Entry_aliasesN": int -> CString.t;
-            val entryAddrType = _import "NetHostDB_Entry_addrType": unit -> int;
-            val entryLength = _import "NetHostDB_Entry_length": unit -> int;
-            val entryNumAddrs = _import "NetHostDB_Entry_numAddrs": unit -> int;
-            val entryAddrsN =
-               _import "NetHostDB_Entry_addrsN": int * pre_in_addr -> unit;
-            val getByAddress =
-               _import "NetHostDB_getByAddress": in_addr * int -> bool;
-            val getByName = _import "NetHostDB_getByName": NullString.t -> bool;
-            val getHostName =
-               _import "NetHostDB_getHostName": char array * int -> int;
-         end
-
-      structure NetProtDB =
-         struct
-            val entryName = _import "NetProtDB_Entry_name": unit -> CString.t;
-            val entryNumAliases = _import "NetProtDB_Entry_numAliases": unit -> int;
-            val entryAliasesN = _import "NetProtDB_Entry_aliasesN": int -> CString.t;
-            val entryProtocol = _import "NetProtDB_Entry_protocol": unit -> int;
-            val getByName = _import "NetProtDB_getByName": NullString.t -> bool;
-            val getByNumber = _import "NetProtDB_getByNumber": int -> bool;
-         end
-
-      structure NetServDB =
-         struct
-            val entryName = _import "NetServDB_Entry_name": unit -> CString.t;
-            val entryNumAliases = _import "NetServDB_Entry_numAliases": unit -> int;
-            val entryAliasesN = _import "NetServDB_Entry_aliasesN": int -> CString.t;
-            val entryPort = _import "NetServDB_Entry_port": unit -> int;
-            val entryProtocol = _import "NetServDB_Entry_protocol": unit -> CString.t;
-            val getByName = _import "NetServDB_getByName": NullString.t * NullString.t -> bool;
-            val getByNameNull = _import "NetServDB_getByNameNull": NullString.t -> bool;
-            val getByPort = _import "NetServDB_getByPort": int * NullString.t -> bool;
-            val getByPortNull = _import "NetServDB_getByPortNull": int -> bool;
-         end
-
-      structure OS =
-         struct
-            structure IO =
-               struct
-                  val POLLIN = _const "OS_IO_POLLIN": word;
-                  val POLLPRI = _const "OS_IO_POLLPRI": word;
-                  val POLLOUT = _const "OS_IO_POLLOUT": word;
-                  val poll = _import "OS_IO_poll": int vector * word vector * 
-                                                int * int * word array -> int;
-               end
-         end
-
-      structure PackReal32 =
-         struct
-            type real = Real32.real
-               
-            val subVec = _import "PackReal32_subVec": word8 vector * int -> real;
-            val subVecRev =
-               _import "PackReal32_subVecRev": word8 vector * int -> real;
-            val update =
-               _import "PackReal32_update": word8 array * int * real -> unit;
-            val updateRev =
-               _import "PackReal32_updateRev": word8 array * int * real -> unit;
-         end
-
-      structure PackReal64 =
-         struct
-            type real = Real64.real
-               
-            val subVec = _import "PackReal64_subVec": word8 vector * int -> real;
-            val subVecRev =
-               _import "PackReal64_subVecRev": word8 vector * int -> real;
-            val update =
-               _import "PackReal64_update": word8 array * int * real -> unit;
-            val updateRev =
-               _import "PackReal64_updateRev": word8 array * int * real -> unit;
-         end
-
-      structure Pointer =
-         struct
-            open Pointer
-
-            val fromWord = _prim "WordU32_toWord32": word -> t;
-            val toWord = _prim "WordU32_toWord32": t -> word;
-               
-            val null: t = fromWord 0w0
-
-            fun isNull p = p = null
-
-            (* val + = _prim "Pointer_add": t * t -> t; *)
-            (* val op < = _prim "Pointer_lt": t * t -> bool; *)
-            (* val - = _prim "Pointer_sub": t * t -> t; *)
-(*            val free = _import "free": t -> unit; *)
-            val getInt8 = _prim "Pointer_getWord8": t * int -> Int8.int;
-            val getInt16 = _prim "Pointer_getWord16": t * int -> Int16.int;
-            val getInt32 = _prim "Pointer_getWord32": t * int -> Int32.int;
-            val getInt64 = _prim "Pointer_getWord64": t * int -> Int64.int;
-            val getPointer = _prim "Pointer_getPointer": t * int -> 'a;
-            val getReal32 = _prim "Pointer_getReal32": t * int -> Real32.real;
-            val getReal64 = _prim "Pointer_getReal64": t * int -> Real64.real;
-            val getWord8 = _prim "Pointer_getWord8": t * int -> Word8.word;
-            val getWord16 = _prim "Pointer_getWord16": t * int -> Word16.word;
-            val getWord32 = _prim "Pointer_getWord32": t * int -> Word32.word;
-            val getWord64 = _prim "Pointer_getWord64": t * int -> Word64.word;
-            val setInt8 = _prim "Pointer_setWord8": t * int * Int8.int -> unit;
-            val setInt16 =
-               _prim "Pointer_setWord16": t * int * Int16.int -> unit;
-            val setInt32 =
-               _prim "Pointer_setWord32": t * int * Int32.int -> unit;
-            val setInt64 = 
-               _prim "Pointer_setWord64": t * int * Int64.int -> unit;
-            val setPointer = _prim "Pointer_setPointer": t * int * 'a -> unit;
-            val setReal32 =
-               _prim "Pointer_setReal32": t * int * Real32.real -> unit;
-            val setReal64 =
-               _prim "Pointer_setReal64": t * int * Real64.real -> unit;
-            val setWord8 =
-               _prim "Pointer_setWord8": t * int * Word8.word -> unit;
-            val setWord16 =
-               _prim "Pointer_setWord16": t * int * Word16.word -> unit;
-            val setWord32 =
-               _prim "Pointer_setWord32": t * int * Word32.word -> unit;
-            val setWord64 =
-               _prim "Pointer_setWord64": t * int * Word64.word -> unit;
-         end
-
-      structure Real64 =
-         struct
-            open Real64
-
-            structure Class =
-               struct
-                  type t = int
-                     
-                  val inf = _const "FP_INFINITE": t;
-                  val nan = _const "FP_NAN": t;
-                  val normal = _const "FP_NORMAL": t;
-                  val subnormal = _const "FP_SUBNORMAL": t;
-                  val zero = _const "FP_ZERO": t;
-               end
-            
-            structure Math =
-               struct
-                  type real = real
-
-                  val acos = _prim "Real64_Math_acos": real -> real;
-                  val asin = _prim "Real64_Math_asin": real -> real;
-                  val atan = _prim "Real64_Math_atan": real -> real;
-                  val atan2 = _prim "Real64_Math_atan2": real * real -> real;
-                  val cos = _prim "Real64_Math_cos": real -> real;
-                  val cosh = _import "cosh": real -> real;
-                  val e = #1 _symbol "Real64_Math_e": real GetSet.t; ()
-                  val exp = _prim "Real64_Math_exp": real -> real;
-                  val ln = _prim "Real64_Math_ln": real -> real;
-                  val log10 = _prim "Real64_Math_log10": real -> real;
-                  val pi = #1 _symbol "Real64_Math_pi": real GetSet.t; ()
-                  val pow = _import "pow": real * real -> real;
-                  val sin = _prim "Real64_Math_sin": real -> real;
-                  val sinh = _import "sinh": real -> real;
-                  val sqrt = _prim "Real64_Math_sqrt": real -> real;
-                  val tan = _prim "Real64_Math_tan": real -> real;
-                  val tanh = _import "tanh": real -> real;
-               end
-
-            val * = _prim "Real64_mul": real * real -> real;
-            val *+ = _prim "Real64_muladd": real * real * real -> real;
-            val *- = _prim "Real64_mulsub": real * real * real -> real;
-            val + = _prim "Real64_add": real * real -> real;
-            val - = _prim "Real64_sub": real * real -> real;
-            val / = _prim "Real64_div": real * real -> real;
-            val op < = _prim "Real64_lt": real * real -> bool;
-            val op <= = _prim "Real64_le": real * real -> bool;
-            val == = _prim "Real64_equal": real * real -> bool;
-            val ?= = _prim "Real64_qequal": real * real -> bool;
-            val abs = _prim "Real64_abs": real -> real;
-            val class = _import "Real64_class": real -> int;
-            val frexp = _import "Real64_frexp": real * int ref -> real;
-            val gdtoa =
-               _import "Real64_gdtoa": real * int * int * int ref -> CString.t;
-            val fromInt = _prim "WordS32_toReal64": int -> real;
-            val ldexp = _prim "Real64_ldexp": real * int -> real;
-            val maxFinite = #1 _symbol "Real64_maxFinite": real GetSet.t; ()
-            val minNormalPos = #1 _symbol "Real64_minNormalPos": real GetSet.t; ()
-            val minPos = #1 _symbol "Real64_minPos": real GetSet.t; ()
-            val modf = _import "Real64_modf": real * real ref -> real;
-            val nextAfter = _import "Real64_nextAfter": real * real -> real;
-            val round = _prim "Real64_round": real -> real;
-            val signBit = _import "Real64_signBit": real -> int;
-            val strto = _import "Real64_strto": NullString.t -> real;
-            val toInt = _prim "Real64_toWordS32": real -> int;
-            val ~ = _prim "Real64_neg": real -> real;
-
-            val fromLarge : real -> real = fn x => x
-            val toLarge : real -> real = fn x => x
-            val precision : int = 53
-            val radix : int = 2
-         end
-      
-      structure Real32 =
-         struct
-            open Real32
-
-            val precision : int = 24
-            val radix : int = 2
-
-            val fromLarge = _prim "Real64_toReal32": real64 -> real;
-            val toLarge = _prim "Real32_toReal64": real -> real64;
-
-            fun unary (f: Real64.real -> Real64.real) (r: real): real =
-               fromLarge (f (toLarge r))
-
-            fun binary (f: Real64.real * Real64.real -> Real64.real)
-               (r: real, r': real): real =
-               fromLarge (f (toLarge r, toLarge r'))
-               
-            structure Math =
-               struct
-                  type real = real
-
-                  val acos = _prim "Real32_Math_acos": real -> real;
-                  val asin = _prim "Real32_Math_asin": real -> real;
-                  val atan = _prim "Real32_Math_atan": real -> real;
-                  val atan2 = _prim "Real32_Math_atan2": real * real -> real;
-                  val cos = _prim "Real32_Math_cos": real -> real;
-                  val cosh = unary Real64.Math.cosh
-                  val e = #1 _symbol "Real32_Math_e": real GetSet.t; ()
-                  val exp = _prim "Real32_Math_exp": real -> real;
-                  val ln = _prim "Real32_Math_ln": real -> real;
-                  val log10 = _prim "Real32_Math_log10": real -> real;
-                  val pi = #1 _symbol "Real32_Math_pi": real GetSet.t; ()
-                  val pow = binary Real64.Math.pow
-                  val sin = _prim "Real32_Math_sin": real -> real;
-                  val sinh = unary Real64.Math.sinh
-                  val sqrt = _prim "Real32_Math_sqrt": real -> real;
-                  val tan = _prim "Real32_Math_tan": real -> real;
-                  val tanh = unary Real64.Math.tanh
-               end
-
-            val * = _prim "Real32_mul": real * real -> real;
-            val *+ = _prim "Real32_muladd": real * real * real -> real;
-            val *- = _prim "Real32_mulsub": real * real * real -> real;
-            val + = _prim "Real32_add": real * real -> real;
-            val - = _prim "Real32_sub": real * real -> real;
-            val / = _prim "Real32_div": real * real -> real;
-            val op < = _prim "Real32_lt": real * real -> bool;
-            val op <= = _prim "Real32_le": real * real -> bool;
-            val == = _prim "Real32_equal": real * real -> bool;
-            val ?= = _prim "Real32_qequal": real * real -> bool;
-            val abs = _prim "Real32_abs": real -> real;
-            val class = _import "Real32_class": real -> int;
-            fun frexp (r: real, ir: int ref): real =
-               fromLarge (Real64.frexp (toLarge r, ir))
-            val gdtoa =
-               _import "Real32_gdtoa": real * int * int * int ref -> CString.t;
-            val fromInt = _prim "WordS32_toReal32": int -> real;
-            val ldexp = _prim "Real32_ldexp": real * int -> real;
-            val maxFinite = #1 _symbol "Real32_maxFinite": real GetSet.t; ()
-            val minNormalPos = #1 _symbol "Real32_minNormalPos": real GetSet.t; ()
-            val minPos = #1 _symbol "Real32_minPos": real GetSet.t; ()
-            val modf = _import "Real32_modf": real * real ref -> real;
-            val signBit = _import "Real32_signBit": real -> int;
-            val strto = _import "Real32_strto": NullString.t -> real;
-            val toInt = _prim "Real32_toWordS32": real -> int;
-            val ~ = _prim "Real32_neg": real -> real;
-         end
-    
-      structure Real32 =
-         struct
-            open Real32
-            local
-               structure S = RealComparisons (Real32)
-            in
-               open S
-            end
-         end
-
-      structure Real64 =
-         struct
-            open Real64
-            local
-               structure S = RealComparisons (Real64)
-            in
-               open S
-            end
-         end
-
-      structure Ref =
-         struct
-            val deref = _prim "Ref_deref": 'a ref -> 'a;
-            val assign = _prim "Ref_assign": 'a ref * 'a -> unit;
-         end
-
-      structure Signal:>
-         sig
-            eqtype t
-            type how
-
-            val fromInt: int -> t
-            val toInt: t -> int
-         end =
-         struct
-            type t = int
-            type how = int
-
-            val fromInt = fn s => s
-            val toInt = fn s => s
-         end
-
-      structure Socket:>
-         sig
-            type sock
-
-            val fromInt: int -> sock
-            val toInt: sock -> int
-         end =
-         struct
-            type sock = int
-
-            fun fromInt i = i
-            fun toInt i = i
-         end
-            
-      structure Socket =
-         struct
-            open Socket
-
-            type pre_sock_addr = word8 array
-            type sock_addr = word8 vector
-            val sockAddrLenMax = _const "Socket_sockAddrLenMax": int;
-            structure AF =
-               struct
-                  type addr_family = int
-                  val UNIX = _const "Socket_AF_UNIX": addr_family;
-                  val INET = _const "Socket_AF_INET": addr_family;
-                  val INET6 = _const "Socket_AF_INET6": addr_family;
-                  val UNSPEC = _const "Socket_AF_UNSPEC": addr_family;
-               end
-            structure SOCK:>
-               sig
-                  eqtype sock_type
-
-                  val fromInt: int -> sock_type
-               end =
-               struct
-                  type sock_type = int
-
-                  val fromInt = fn i => i
-               end
-            structure SOCK =
-               struct
-                  open SOCK
-                  val STREAM = _const "Socket_SOCK_STREAM": sock_type;
-                  val DGRAM = _const "Socket_SOCK_DGRAM": sock_type;
-               end
-            structure CtlExtra =
-               struct
-                  type level = int
-                  type optname = int
-                  type request = int
-                  (* host byte order (LSB) *)
-                  type read_data = word8 vector
-                  type write_data = word8 array
-
-                  val setSockOpt = 
-                     _import "Socket_Ctl_setSockOpt": sock * level * optname * 
-                                                   read_data * int -> 
-                                                   int;
-                  val getSockOpt = 
-                     _import "Socket_Ctl_getSockOpt": sock * level * optname * 
-                                                   write_data * int ref -> 
-                                                   int;
-                  val setIOCtl =
-                     _import "Socket_Ctl_getsetIOCtl": sock * request *
-                                                    read_data ->
-                                                    int;
-                  val getIOCtl =
-                     _import "Socket_Ctl_getsetIOCtl": sock * request *
-                                                    write_data ->
-                                                    int;
-               end
-            structure Ctl =
-               struct
-                  open CtlExtra
-                  val SOCKET = _const "Socket_Ctl_SOL_SOCKET": level;
-                  val DEBUG = _const "Socket_Ctl_SO_DEBUG": optname;
-                  val REUSEADDR = _const "Socket_Ctl_SO_REUSEADDR": optname;
-                  val KEEPALIVE = _const "Socket_Ctl_SO_KEEPALIVE": optname;
-                  val DONTROUTE = _const "Socket_Ctl_SO_DONTROUTE": optname;
-                  val LINGER = _const "Socket_Ctl_SO_LINGER": optname;
-                  val BROADCAST = _const "Socket_Ctl_SO_BROADCAST": optname;
-                  val OOBINLINE = _const "Socket_Ctl_SO_OOBINLINE": optname;
-                  val SNDBUF = _const "Socket_Ctl_SO_SNDBUF": optname;
-                  val RCVBUF = _const "Socket_Ctl_SO_RCVBUF": optname;
-                  val TYPE = _const "Socket_Ctl_SO_TYPE": optname;
-                  val ERROR = _const "Socket_Ctl_SO_ERROR": optname;
-
-                  val getPeerName =
-                     _import "Socket_Ctl_getPeerName": sock * pre_sock_addr * int ref -> int;
-                  val getSockName =
-                     _import "Socket_Ctl_getSockName": sock * pre_sock_addr * int ref -> int;
-
-                  (* val NBIO = _const "Socket_Ctl_FIONBIO": request; *)
-                  val NREAD = _const "Socket_Ctl_FIONREAD": request;
-                  val ATMARK = _const "Socket_Ctl_SIOCATMARK": request;
-               end
-
-            val familyOfAddr =
-               _import "Socket_familyOfAddr": sock_addr -> AF.addr_family;
-            val bind = _import "Socket_bind": sock * sock_addr * int -> int;
-            val listen = _import "Socket_listen": sock * int -> int;
-            val connect =
-               _import "Socket_connect": sock * sock_addr * int -> int;
-            val accept =
-               _import "Socket_accept": sock * pre_sock_addr * int ref -> int;
-            val close = _import "Socket_close": sock -> int;
-
-            type how = int
-            val SHUT_RD = _const "Socket_SHUT_RD": how;
-            val SHUT_WR = _const "Socket_SHUT_WR": how;
-            val SHUT_RDWR = _const "Socket_SHUT_RDWR": how;
-            val shutdown = _import "Socket_shutdown": sock * how -> int;
-
-            type flags = word
-            val MSG_DONTROUTE = _const "Socket_MSG_DONTROUTE": flags;
-            val MSG_DONTWAIT = _const "Socket_MSG_DONTWAIT": flags;
-            val MSG_OOB = _const "Socket_MSG_OOB": flags;
-            val MSG_PEEK = _const "Socket_MSG_PEEK": flags;
-
-            val sendArr = _import "Socket_send":
-               sock * word8 array * int * int * word -> int;
-            val sendVec = _import "Socket_send":
-               sock * word8 vector * int * int * word -> int;
-            val sendToArr = _import "Socket_sendTo":
-               sock * word8 array * int * int * word * sock_addr * int -> int;
-            val sendToVec = _import "Socket_sendTo":
-               sock * word8 vector * int * int * word * sock_addr * int -> int;
-            val recv = _import "Socket_recv":
-               sock * word8 array * int * int * word -> int;
-            val recvFrom = _import "Socket_recvFrom":
-               sock * word8 array * int * int * word * pre_sock_addr * int ref
-               -> int;
-
-            structure GenericSock =
-               struct
-                  val socket = 
-                     _import "GenericSock_socket": AF.addr_family * 
-                                                SOCK.sock_type * 
-                                                int -> int;
-                  val socketPair = 
-                     _import "GenericSock_socketPair": AF.addr_family * 
-                                                    SOCK.sock_type * 
-                                                    int * 
-                                                    int ref * int ref -> int;
-               end
-
-            structure INetSock =
-               struct
-                  val toAddr = _import "INetSock_toAddr": NetHostDB.in_addr * int * 
-                                                       pre_sock_addr * int ref -> unit;
-                  val fromAddr = _import "INetSock_fromAddr": sock_addr -> unit;
-                  val getInAddr = _import "INetSock_getInAddr": NetHostDB.pre_in_addr -> 
-                                                             unit;
-                  val getPort = _import "INetSock_getPort": unit -> int;
-                  structure TCP =
-                     struct
-                        open CtlExtra
-                        val TCP = _const "Socket_INetSock_TCP_SOL_TCP": level;
-                        val NODELAY = _const "Socket_INetSock_TCP_SO_NODELAY": optname;
-                     end
-               end
-            structure UnixSock =
-               struct
-                  val toAddr =
-                     _import "UnixSock_toAddr"
-                     : NullString.t * int * pre_sock_addr * int ref -> unit;
-                  val pathLen = _import "UnixSock_pathLen": sock_addr -> int;
-                  val fromAddr =
-                     _import "UnixSock_fromAddr"
-                     : sock_addr * char array * int -> unit;
-               end
-         end
-
-      structure Status:>
-         sig
-            eqtype t
-
-            val failure: t
-            val fromInt: int -> t
-            val success: t
-            val toInt: t -> int
-         end =
-         struct
-            type t = int
-
-            val failure = 1
-            val fromInt = fn i => i
-            val success = 0
-            val toInt = fn i => i
-         end
-
-      val halt = _prim "MLton_halt": Status.t -> unit;
-
-      structure String =
-         struct
-            val fromWord8Vector =
-               _prim "Word8Vector_toString": word8 vector -> string;
-            val toWord8Vector =
-               _prim "String_toWord8Vector": string -> word8 vector;
-         end
-
-      structure TextIO =
-         struct
-            val bufSize = _command_line_const "TextIO.bufSize": int = 4096;
-         end
-      
-      structure Thread =
-         struct
-            type preThread = PreThread.t
-            type thread = Thread.t
-
-            val atomicBegin = _prim "Thread_atomicBegin": unit -> unit;
-            val canHandle = _prim "Thread_canHandle": unit -> int;
-            fun atomicEnd () =
-               if Int.<= (canHandle (), 0)
-                  then raise Fail "Thread.atomicEnd with no atomicBegin"
-               else _prim "Thread_atomicEnd": unit -> unit; ()
-            val copy = _prim "Thread_copy": preThread -> thread;
-            (* copyCurrent's result is accesible via savedPre ().
-             * It is not possible to have the type of copyCurrent as
-             * unit -> preThread, because there are two different ways to
-             * return from the call to copyCurrent.  One way is the direct
-             * obvious way, in the thread that called copyCurrent.  That one,
-             * of course, wants to call savedPre ().  However, another way to
-             * return is by making a copy of the preThread and then switching
-             * to it.  In that case, there is no preThread to return.  Making
-             * copyCurrent return a preThread creates nasty bugs where the
-             * return code from the CCall expects to see a preThread result
-             * according to the C return convention, but there isn't one when
-             * switching to a copy.
-             *)
-            val copyCurrent = _prim "Thread_copyCurrent": unit -> unit;
-            val current = _import "GC_getCurrentThread": GCState.t -> thread;
-            val finishSignalHandler = _import "GC_finishSignalHandler": GCState.t -> unit;
-            val returnToC = _prim "Thread_returnToC": unit -> unit;
-            val saved = _import "GC_getSavedThread": GCState.t -> thread;
-            val savedPre = _import "GC_getSavedThread": GCState.t -> preThread;
-            val setCallFromCHandler =
-               _import "GC_setCallFromCHandlerThread": GCState.t * thread -> unit;
-            val setSignalHandler = _import "GC_setSignalHandlerThread": GCState.t * thread -> unit;
-            val setSaved = _import "GC_setSavedThread": GCState.t * thread -> unit;
-            val startSignalHandler = _import "GC_startSignalHandler": GCState.t -> unit;
-            val switchTo = _prim "Thread_switchTo": thread -> unit;
-         end      
-
-      structure Time =
-         struct
-            val gettimeofday = _import "Time_gettimeofday": unit -> int;
-            val sec = _import "Time_sec": unit -> int;
-            val usec = _import "Time_usec": unit -> int;
-         end
-
-      structure TopLevel =
-         struct
-            val setHandler =
-               _prim "TopLevel_setHandler": (exn -> unit) -> unit;
-            val setSuffix =
-               _prim "TopLevel_setSuffix": (unit -> unit) -> unit;
-         end
-
-      structure Vector =
-         struct
-            val sub = _prim "Vector_sub": 'a vector * int -> 'a;
-            val length = _prim "Vector_length": 'a vector -> int;
-
-            (* Don't mutate the array after you apply fromArray, because vectors
-             * are supposed to be immutable and the optimizer depends on this.
-             *)
-            val fromArray = _prim "Array_toVector": 'a array -> 'a vector;
-         end
-
-      structure Word1 =
-         struct
-            type big = Word8.word
-            type word = word1
-            val fromBigUnsafe = _prim "WordU8_toWord1": big -> word;
-            val toBig = _prim "WordU1_toWord8": word -> big;
-            val wordSize = 1
-         end
-      structure Word2 =
-         struct
-            type big = Word8.word
-            type word = word2
-            val fromBigUnsafe = _prim "WordU8_toWord2": big -> word;
-            val toBig = _prim "WordU2_toWord8": word -> big;
-            val wordSize = 2
-         end
-      structure Word3 =
-         struct
-            type big = Word8.word
-            type word = word3
-            val fromBigUnsafe = _prim "WordU8_toWord3": big -> word;
-            val toBig = _prim "WordU3_toWord8": word -> big;
-            val wordSize = 3
-         end
-      structure Word4 =
-         struct
-            type big = Word8.word
-            type word = word4
-            val fromBigUnsafe = _prim "WordU8_toWord4": big -> word;
-            val toBig = _prim "WordU4_toWord8": word -> big;
-            val wordSize = 4
-         end
-      structure Word5 =
-         struct
-            type big = Word8.word
-            type word = word5
-            val fromBigUnsafe = _prim "WordU8_toWord5": big -> word;
-            val toBig = _prim "WordU5_toWord8": word -> big;
-            val wordSize = 5
-         end
-      structure Word6 =
-         struct
-            type big = Word8.word
-            type word = word6
-            val fromBigUnsafe = _prim "WordU8_toWord6": big -> word;
-            val toBig = _prim "WordU6_toWord8": word -> big;
-            val wordSize = 6
-         end
-      structure Word7 =
-         struct
-            type big = Word8.word
-            type word = word7
-            val fromBigUnsafe = _prim "WordU8_toWord7": big -> word;
-            val toBig = _prim "WordU7_toWord8": word -> big;
-            val wordSize = 7
-         end
-      structure Word8 =
-         struct
-            open Word8
-               
-            val wordSize: int = 8
-
-            val + = _prim "Word8_add": word * word -> word;
-            val andb = _prim "Word8_andb": word * word -> word;
-            val ~>> = _prim "WordS8_rshift": word * Word.word -> word;
-            val div = _prim "WordU8_quot": word * word -> word;
-            val fromInt = _prim "WordU32_toWord8": int -> word;
-            val fromLarge = _prim "WordU64_toWord8": LargeWord.word -> word;
-            val << = _prim "Word8_lshift": word * Word.word -> word;
-            val op < = _prim "WordU8_lt": word * word -> bool;
-            val mod = _prim "WordU8_rem": word * word -> word;
-            val * = _prim "WordU8_mul": word * word -> word;
-            val ~ = _prim "Word8_neg": word -> word;
-            val notb = _prim "Word8_notb": word -> word;
-            val orb = _prim "Word8_orb": word * word -> word;
-            val rol = _prim "Word8_rol": word * Word.word -> word;
-            val ror = _prim "Word8_ror": word * Word.word -> word;
-            val >> = _prim "WordU8_rshift": word * Word.word -> word;
-            val - = _prim "Word8_sub": word * word -> word;
-            val toInt = _prim "WordU8_toWord32": word -> int;
-            val toIntX = _prim "WordS8_toWord32": word -> int;
-            val toLarge = _prim "WordU8_toWord64": word -> LargeWord.word;
-            val toLargeX = _prim "WordS8_toWord64": word -> LargeWord.word;
-            val xorb = _prim "Word8_xorb": word * word -> word;
-         end
-      structure Word8 =
-         struct
-            open Word8
-            local
-               structure S = Comparisons (Word8)
-            in
-               open S
-            end
-         end
-      structure Word8Array =
-         struct
-            val subWord =
-               _prim "Word8Array_subWord": word8 array * int -> word;
-            val subWordRev =
-               _import "Word8Array_subWord32Rev": word8 array * int -> word;
-            val updateWord =
-               _prim "Word8Array_updateWord": word8 array * int * word -> unit;
-            val updateWordRev =
-               _import "Word8Array_updateWord32Rev": word8 array * int * word -> unit;
-         end
-      structure Word8Vector =
-         struct
-            val subWord =
-               _prim "Word8Vector_subWord": word8 vector * int -> word;
-            val subWordRev =
-               _import "Word8Vector_subWord32Rev": word8 vector * int -> word;
-         end
-      structure Word9 =
-         struct
-            type big = Word16.word
-            type word = word9
-            val fromBigUnsafe = _prim "WordU16_toWord9": big -> word;
-            val toBig = _prim "WordU9_toWord16": word -> big;
-            val wordSize = 9
-         end
-      structure Word10 =
-         struct
-            type big = Word16.word
-            type word = word10
-            val fromBigUnsafe = _prim "WordU16_toWord10": big -> word;
-            val toBig = _prim "WordU10_toWord16": word -> big;
-            val wordSize = 10
-         end
-      structure Word11 =
-         struct
-            type big = Word16.word
-            type word = word11
-            val fromBigUnsafe = _prim "WordU16_toWord11": big -> word;
-            val toBig = _prim "WordU11_toWord16": word -> big;
-            val wordSize = 11
-         end
-      structure Word12 =
-         struct
-            type big = Word16.word
-            type word = word12
-            val fromBigUnsafe = _prim "WordU16_toWord12": big -> word;
-            val toBig = _prim "WordU12_toWord16": word -> big;
-            val wordSize = 12
-         end
-      structure Word13 =
-         struct
-            type big = Word16.word
-            type word = word13
-            val fromBigUnsafe = _prim "WordU16_toWord13": big -> word;
-            val toBig = _prim "WordU13_toWord16": word -> big;
-            val wordSize = 13
-         end
-      structure Word14 =
-         struct
-            type big = Word16.word
-            type word = word14
-            val fromBigUnsafe = _prim "WordU16_toWord14": big -> word;
-            val toBig = _prim "WordU14_toWord16": word -> big;
-            val wordSize = 14
-         end
-      structure Word15 =
-         struct
-            type big = Word16.word
-            type word = word15
-            val fromBigUnsafe = _prim "WordU16_toWord15": big -> word;
-            val toBig = _prim "WordU15_toWord16": word -> big;
-            val wordSize = 15
-         end
-      structure Word16 =
-         struct
-            open Word16
-               
-            val wordSize: int = 16
-
-            val + = _prim "Word16_add": word * word -> word;
-            val andb = _prim "Word16_andb": word * word -> word;
-            val ~>> = _prim "WordS16_rshift": word * Word.word -> word;
-            val div = _prim "WordU16_quot": word * word -> word;
-            val fromInt = _prim "WordU32_toWord16": int -> word;
-            val fromLarge = _prim "WordU64_toWord16": LargeWord.word -> word;
-            val << = _prim "Word16_lshift": word * Word.word -> word;
-            val op < = _prim "WordU16_lt": word * word -> bool;
-            val mod = _prim "WordU16_rem": word * word -> word;
-            val * = _prim "WordU16_mul": word * word -> word;
-            val ~ = _prim "Word16_neg": word -> word;
-            val notb = _prim "Word16_notb": word -> word;
-            val orb = _prim "Word16_orb": word * word -> word;
-            val >> = _prim "WordU16_rshift": word * Word.word -> word;
-            val - = _prim "Word16_sub": word * word -> word;
-            val toInt = _prim "WordU16_toWord32": word -> int;
-            val toIntX = _prim "WordS16_toWord32": word -> int;
-            val toLarge = _prim "WordU16_toWord64": word -> LargeWord.word;
-            val toLargeX = _prim "WordS16_toWord64": word -> LargeWord.word;
-            val xorb = _prim "Word16_xorb": word * word -> word;
-         end
-      structure Word16 =
-         struct
-            open Word16
-            local
-               structure S = Comparisons (Word16)
-            in
-               open S
-            end
-         end
-      structure Word17 =
-         struct
-            type big = Word32.word
-            type word = word17
-            val fromBigUnsafe = _prim "WordU32_toWord17": big -> word;
-            val toBig = _prim "WordU17_toWord32": word -> big;
-            val wordSize = 17
-         end
-      structure Word18 =
-         struct
-            type big = Word32.word
-            type word = word18
-            val fromBigUnsafe = _prim "WordU32_toWord18": big -> word;
-            val toBig = _prim "WordU18_toWord32": word -> big;
-            val wordSize = 18
-         end
-      structure Word19 =
-         struct
-            type big = Word32.word
-            type word = word19
-            val fromBigUnsafe = _prim "WordU32_toWord19": big -> word;
-            val toBig = _prim "WordU19_toWord32": word -> big;
-            val wordSize = 19
-         end
-      structure Word20 =
-         struct
-            type big = Word32.word
-            type word = word20
-            val fromBigUnsafe = _prim "WordU32_toWord20": big -> word;
-            val toBig = _prim "WordU20_toWord32": word -> big;
-            val wordSize = 20
-         end
-      structure Word21 =
-         struct
-            type big = Word32.word
-            type word = word21
-            val fromBigUnsafe = _prim "WordU32_toWord21": big -> word;
-            val toBig = _prim "WordU21_toWord32": word -> big;
-            val wordSize = 21
-         end
-      structure Word22 =
-         struct
-            type big = Word32.word
-            type word = word22
-            val fromBigUnsafe = _prim "WordU32_toWord22": big -> word;
-            val toBig = _prim "WordU22_toWord32": word -> big;
-            val wordSize = 22
-         end
-      structure Word23 =
-         struct
-            type big = Word32.word
-            type word = word23
-            val fromBigUnsafe = _prim "WordU32_toWord23": big -> word;
-            val toBig = _prim "WordU23_toWord32": word -> big;
-            val wordSize = 23
-         end
-      structure Word24 =
-         struct
-            type big = Word32.word
-            type word = word24
-            val fromBigUnsafe = _prim "WordU32_toWord24": big -> word;
-            val toBig = _prim "WordU24_toWord32": word -> big;
-            val wordSize = 24
-         end
-      structure Word25 =
-         struct
-            type big = Word32.word
-            type word = word25
-            val fromBigUnsafe = _prim "WordU32_toWord25": big -> word;
-            val toBig = _prim "WordU25_toWord32": word -> big;
-            val wordSize = 25
-         end
-      structure Word26 =
-         struct
-            type big = Word32.word
-            type word = word26
-            val fromBigUnsafe = _prim "WordU32_toWord26": big -> word;
-            val toBig = _prim "WordU26_toWord32": word -> big;
-            val wordSize = 26
-         end
-      structure Word27 =
-         struct
-            type big = Word32.word
-            type word = word27
-            val fromBigUnsafe = _prim "WordU32_toWord27": big -> word;
-            val toBig = _prim "WordU27_toWord32": word -> big;
-            val wordSize = 27
-         end
-      structure Word28 =
-         struct
-            type big = Word32.word
-            type word = word28
-            val fromBigUnsafe = _prim "WordU32_toWord28": big -> word;
-            val toBig = _prim "WordU28_toWord32": word -> big;
-            val wordSize = 28
-         end
-      structure Word29 =
-         struct
-            type big = Word32.word
-            type word = word29
-            val fromBigUnsafe = _prim "WordU32_toWord29": big -> word;
-            val toBig = _prim "WordU29_toWord32": word -> big;
-            val wordSize = 29
-         end
-      structure Word30 =
-         struct
-            type big = Word32.word
-            type word = word30
-            val fromBigUnsafe = _prim "WordU32_toWord30": big -> word;
-            val toBig = _prim "WordU30_toWord32": word -> big;
-            val wordSize = 30
-         end
-      structure Word31 =
-         struct
-            type big = Word32.word
-            type word = word31
-            val fromBigUnsafe = _prim "WordU32_toWord31": big -> word;
-            val toBig = _prim "WordU31_toWord32": word -> big;
-            val wordSize = 31
-         end
-      structure Word32 =
-         struct
-            open Word32
-               
-            val wordSize: int = 32
-
-            val + = _prim "Word32_add": word * word -> word;
-            val andb = _prim "Word32_andb": word * word -> word;
-            val ~>> = _prim "WordS32_rshift": word * word -> word;
-            val div = _prim "WordU32_quot": word * word -> word;
-            val fromInt = _prim "WordU32_toWord32": int -> word;
-            val fromLarge = _prim "WordU64_toWord32": LargeWord.word -> word;
-            val << = _prim "Word32_lshift": word * word -> word;
-            val op < = _prim "WordU32_lt": word * word -> bool;
-            val mod = _prim "WordU32_rem": word * word -> word;
-            val * = _prim "WordU32_mul": word * word -> word;
-            val ~ = _prim "Word32_neg": word -> word;
-            val notb = _prim "Word32_notb": word -> word;
-            val orb = _prim "Word32_orb": word * word -> word;
-            val rol = _prim "Word32_rol": word * word -> word;
-            val ror = _prim "Word32_ror": word * word -> word;
-            val >> = _prim "WordU32_rshift": word * word -> word;
-            val - = _prim "Word32_sub": word * word -> word;
-            val toInt = _prim "WordU32_toWord32": word -> int;
-            val toIntX = _prim "WordS32_toWord32": word -> int;
-            val toLarge = _prim "WordU32_toWord64": word -> LargeWord.word;
-            val toLargeX = _prim "WordS32_toWord64": word -> LargeWord.word;
-            val xorb = _prim "Word32_xorb": word * word -> word;
-         end
-      structure Word32 =
-         struct
-            open Word32
-            local
-               structure S = Comparisons (Word32)
-            in
-               open S
-            end
-         end
-      structure Word = Word32
-      structure Word64 =
-         struct
-            open Word64
-               
-            val wordSize: int = 64
-
-            val + = _prim "Word64_add": word * word -> word;
-            val andb = _prim "Word64_andb": word * word -> word;
-            val ~>> = _prim "WordS64_rshift": word * Word.word -> word;
-            val div = _prim "WordU64_quot": word * word -> word;
-            val fromInt = _prim "WordS32_toWord64": int -> word;
-            val fromLarge: LargeWord.word -> word = fn x => x
-            val << = _prim "Word64_lshift": word * Word.word -> word;
-            val op < = _prim "WordU64_lt": word * word -> bool;
-            val mod = _prim "WordU64_rem": word * word -> word;
-            val * = _prim "WordU64_mul": word * word -> word;
-            val ~ = _prim "Word64_neg": word -> word;
-            val notb = _prim "Word64_notb": word -> word;
-            val orb = _prim "Word64_orb": word * word -> word;
-            val >> = _prim "WordU64_rshift": word * Word.word -> word;
-            val - = _prim "Word64_sub": word * word -> word;
-            val toInt = _prim "WordU64_toWord32": word -> int;
-            val toIntX = _prim "WordU64_toWord32": word -> int;
-            val toLarge: word -> LargeWord.word = fn x => x
-            val toLargeX: word -> LargeWord.word = fn x => x
-            val xorb = _prim "Word64_xorb": word * word -> word;
-         end
-      structure Word64 =
-         struct
-            open Word64
-            local
-               structure S = Comparisons (Word64)
-            in
-               open S
-            end
-         end
-
-      structure Cygwin =
-         struct
-            val toFullWindowsPath =
-               _import "Cygwin_toFullWindowsPath": NullString.t -> CString.t;
-         end
-
-      structure FileDesc:>
-         sig
-            eqtype t
-
-            val fromWord: word -> t
-            val fromInt: int -> t
-            val toInt: t -> int
-            val toWord: t -> word
-         end =
-         struct
-            type t = int
-
-            val fromWord = Word32.toInt
-            fun fromInt i = i
-            fun toInt i = i
-            val toWord = Word32.fromInt
-         end
-
-      structure Windows =
-         struct
-            structure Process =
-               struct
-                  val create = 
-                     _import "Windows_Process_create"
-                     : (NullString.t * NullString.t * NullString.t
-                        * FileDesc.t * FileDesc.t * FileDesc.t) -> Pid.t;
-                  val terminate =
-                     _import "Windows_terminate": Pid.t * Signal.t -> int;
-               end
-         end
-
-      structure World =
-         struct
-            val getAmOriginal = _import "GC_getAmOriginal": GCState.t -> bool;
-            val setAmOriginal = _import "GC_setAmOriginal": GCState.t * bool -> unit;
-            val save = _prim "World_save": word (* filedes *) -> unit;
-         end
-   end
-
-structure Primitive =
-   struct
-      open Primitive
-
-      structure Int32 =
-         struct
-            open Int32
-               
-            local
-               fun make f (i: int, i': int): bool =
-                  f (Primitive.Word32.fromInt i, Primitive.Word32.fromInt i')
-            in
-               val geu = make Primitive.Word32.>=
-               val gtu = make Primitive.Word32.> 
-            end
-         end
-      structure Int = Int32
-   end
-
-structure NullString =
-   struct
-      open NullString
-
-      fun fromString s =
-         if #"\000" = let
-                         open Primitive
-                      in
-                         Vector.sub (s, Int.- (Vector.length s, 1))
-                      end
-            then NullString.fromString s
-         else raise Fail "NullString.fromString"
-
-      val empty = fromString "\000"
-   end
-
-(* Quell unused warnings. *)
-local
-   val _ = #"a": Char2.t: Char2.char
-   val _ = #"a": Char4.t: Char4.char
-   val _ = "a": String2.t: String2.string
-   val _ = "a": String4.t: String4.string
-   open Primitive
-   open Char2
-   val _ = op <
-   val _ = chr
-   val _ = ord
-   open Char4
-   val _ = op <
-   val _ = chr
-   val _ = ord
-   open Int64
-   val _ = << 
-   val _ = >>
-   val _ = ~>>
-   val _ = andb
-in
-end
-
-(* Install an emergency exception handler. *)
-local
-   open Primitive
-   val _ =
-      TopLevel.setHandler 
-      (fn exn => 
-       (Stdio.print "unhandled exception: "
-        ; case exn of
-             Fail msg => (Stdio.print "Fail "
-                          ; Stdio.print msg)
-           | _ => Stdio.print (Exn.name exn)
-        ; Stdio.print "\n"
-        ; bug (NullString.fromString 
-               "unhandled exception in Basis Library\000")))
-in
-end

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library/mlton/ffi.sig
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library/mlton/ffi.sig	2006-01-28 17:09:17 UTC (rev 4323)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/mlton/ffi.sig	2006-01-28 17:54:57 UTC (rev 4324)
@@ -11,8 +11,8 @@
       val atomicEnd: unit -> unit
       val getBool: int -> bool
       val getChar8: int -> Char.char
-      val getChar16: int -> Char2.char
-      val getChar32: int -> Char4.char
+      val getChar16: int -> Char16.char
+      val getChar32: int -> Char32.char
       val getInt8: int -> Int8.int
       val getInt16: int -> Int16.int
       val getInt32: int -> Int32.int
@@ -27,8 +27,8 @@
       val register: int * (unit -> unit) -> unit
       val setBool: bool -> unit
       val setChar8: Char.char -> unit
-      val setChar16: Char2.char -> unit
-      val setChar32: Char4.char -> unit
+      val setChar16: Char16.char -> unit
+      val setChar32: Char32.char -> unit
       val setInt8: Int8.int -> unit
       val setInt16: Int16.int -> unit
       val setInt32: Int32.int -> unit

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library/mlton/rusage.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library/mlton/rusage.sml	2006-01-28 17:09:17 UTC (rev 4323)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/mlton/rusage.sml	2006-01-28 17:54:57 UTC (rev 4324)
@@ -9,7 +9,6 @@
 structure MLtonRusage: MLTON_RUSAGE =
    struct
       structure Prim = Primitive.MLton.Rusage
-      val gcState = Primitive.GCState.gcState
 
       type t = {utime: Time.time, stime: Time.time}
 
@@ -37,7 +36,7 @@
          in
             fn () =>
             let
-               val () = Prim.ru gcState
+               val () = Prim.ru ()
                open Prim
             in
                {children = collect (children_utime_sec, children_utime_usec,

Deleted: mlton/branches/on-20050822-x86_64-branch/basis-library/posix/primitive.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library/posix/primitive.sml	2006-01-28 17:09:17 UTC (rev 4323)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/posix/primitive.sml	2006-01-28 17:54:57 UTC (rev 4324)
@@ -1,758 +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.
- *)
-
-structure PosixPrimitive =
-   struct
-      type cstring = Pointer.t
-      type cstringArray = Pointer.t
-
-      type uid = word
-      type gid = word
-      type size = int
-      type ssize = int
-      type mode = word
-      type time = int
-
-      structure FileDesc = Primitive.FileDesc
-      type file_desc = FileDesc.t
-      type fd = file_desc
-         
-      structure Error =
-         struct
-            type syserror = int
-
-            val getErrno = _import "Posix_Error_getErrno": unit -> int;
-            val clearErrno = _import "Posix_Error_clearErrno": unit -> unit;
-            val strerror = _import "Posix_Error_strerror": syserror -> cstring;
-
-            val acces = _const "Posix_Error_acces": syserror;
-            val again = _const "Posix_Error_again": syserror;
-            val badf = _const "Posix_Error_badf": syserror;
-            val badmsg = _const "Posix_Error_badmsg": syserror;
-            val busy = _const "Posix_Error_busy": syserror;
-            val canceled = _const "Posix_Error_canceled": syserror;
-            val child = _const "Posix_Error_child": syserror;
-            val deadlk = _const "Posix_Error_deadlk": syserror;
-            val dom = _const "Posix_Error_dom": syserror;
-            val exist = _const "Posix_Error_exist": syserror;
-            val fault = _const "Posix_Error_fault": syserror;
-            val fbig = _const "Posix_Error_fbig": syserror;
-            val inprogress = _const "Posix_Error_inprogress": syserror;
-            val intr = _const "Posix_Error_intr": syserror;
-            val inval = _const "Posix_Error_inval": syserror;
-            val io = _const "Posix_Error_io": syserror;
-            val isdir = _const "Posix_Error_isdir": syserror;
-            val loop = _const "Posix_Error_loop": syserror;
-            val mfile = _const "Posix_Error_mfile": syserror;
-            val mlink = _const "Posix_Error_mlink": syserror;
-            val msgsize = _const "Posix_Error_msgsize": syserror;
-            val nametoolong = _const "Posix_Error_nametoolong": syserror;
-            val nfile = _const "Posix_Error_nfile": syserror;
-            val nodev = _const "Posix_Error_nodev": syserror;
-            val noent = _const "Posix_Error_noent": syserror;
-            val noexec = _const "Posix_Error_noexec": syserror;
-            val nolck = _const "Posix_Error_nolck": syserror;
-            val nomem = _const "Posix_Error_nomem": syserror;
-            val nospc = _const "Posix_Error_nospc": syserror;
-            val nosys = _const "Posix_Error_nosys": syserror;
-            val notdir = _const "Posix_Error_notdir": syserror;
-            val notempty = _const "Posix_Error_notempty": syserror;
-            val notsup = _const "Posix_Error_notsup": syserror;
-            val notty = _const "Posix_Error_notty": syserror;
-            val nxio = _const "Posix_Error_nxio": syserror;
-            val perm = _const "Posix_Error_perm": syserror;
-            val pipe = _const "Posix_Error_pipe": syserror;
-            val range = _const "Posix_Error_range": syserror;
-            val rofs = _const "Posix_Error_rofs": syserror;
-            val spipe = _const "Posix_Error_spipe": syserror;
-            val srch = _const "Posix_Error_srch": syserror;
-            val toobig = _const "Posix_Error_toobig": syserror;
-            val xdev = _const "Posix_Error_xdev": syserror;
-
-            val errorNames =
-               [
-                (acces, "acces"),
-                (again, "again"),
-                (badf, "badf"),
-                (badmsg, "badmsg"),
-                (busy, "busy"),
-                (canceled, "canceled"),
-                (child, "child"),
-                (deadlk, "deadlk"),
-                (dom, "dom"),
-                (exist, "exist"),
-                (fault, "fault"),
-                (fbig, "fbig"),
-                (inprogress, "inprogress"),
-                (intr, "intr"),
-                (inval, "inval"),
-                (io, "io"),
-                (isdir, "isdir"),
-                (loop, "loop"),
-                (mfile, "mfile"),
-                (mlink, "mlink"),
-                (msgsize, "msgsize"),
-                (nametoolong, "nametoolong"),
-                (nfile, "nfile"),
-                (nodev, "nodev"),
-                (noent, "noent"),
-                (noexec, "noexec"),
-                (nolck, "nolck"),
-                (nomem, "nomem"),
-                (nospc, "nospc"),
-                (nosys, "nosys"),
-                (notdir, "notdir"),
-                (notempty, "notempty"),
-                (notsup, "notsup"),
-                (notty, "notty"),
-                (nxio, "nxio"),
-                (perm, "perm"),
-                (pipe, "pipe"),
-                (range, "range"),
-                (rofs, "rofs"),
-                (spipe, "spipe"),
-                (srch, "srch"),
-                (toobig, "toobig"),
-                (xdev, "xdev")
-                ]
-         end
-      
-      structure Signal =
-         struct
-            open Primitive.Signal
-               
-            val abrt = _const "Posix_Signal_abrt": t;
-            val alrm = _const "Posix_Signal_alrm": t;
-            val bus = _const "Posix_Signal_bus": t;
-            val chld = _const "Posix_Signal_chld": t;
-            val cont = _const "Posix_Signal_cont": t;
-            val fpe = _const "Posix_Signal_fpe": t;
-            val hup = _const "Posix_Signal_hup": t;
-            val ill = _const "Posix_Signal_ill": t;
-            val int = _const "Posix_Signal_int": t;
-            val kill = _const "Posix_Signal_kill": t;
-            val pipe = _const "Posix_Signal_pipe": t;
-            val prof = _const "Posix_Signal_prof": t;
-            val quit = _const "Posix_Signal_quit": t;
-            val segv = _const "Posix_Signal_segv": t;
-            val stop = _const "Posix_Signal_stop": t;
-            val term = _const "Posix_Signal_term": t;
-            val tstp = _const "Posix_Signal_tstp": t;
-            val ttin = _const "Posix_Signal_ttin": t;
-            val ttou = _const "Posix_Signal_ttou": t;
-            val usr1 = _const "Posix_Signal_usr1": t;
-            val usr2 = _const "Posix_Signal_usr2": t;
-            val vtalrm = _const "Posix_Signal_vtalrm": t;
-
-            val block = _const "Posix_Signal_block": how;
-            val default = _import "Posix_Signal_default": t -> int;
-            val handleGC = _import "Posix_Signal_handleGC": unit -> unit;
-            val handlee = _import "Posix_Signal_handle": t -> int;
-            val ignore = _import "Posix_Signal_ignore": t -> int;
-            val isDefault =
-               _import "Posix_Signal_isDefault": t * bool ref -> int;
-            val isGCPending = _import "Posix_Signal_isGCPending": unit -> bool;
-            val isPending = _import "Posix_Signal_isPending": t -> bool;
-            val numSignals = _const "Posix_Signal_numSignals": int;
-            val resetPending = _import "Posix_Signal_resetPending": unit -> unit;
-            val setmask = _const "Posix_Signal_setmask": how;
-            val sigaddset = _import "Posix_Signal_sigaddset": t -> int;
-            val sigdelset = _import "Posix_Signal_sigdelset": t -> int;
-            val sigemptyset = _import "Posix_Signal_sigemptyset": unit -> int;
-            val sigfillset = _import "Posix_Signal_sigfillset": unit -> int;
-            val sigismember = _import "Posix_Signal_sigismember": t -> int;
-            val sigprocmask = _import "Posix_Signal_sigprocmask": how -> int;
-            val suspend = _import "Posix_Signal_suspend": unit -> unit;
-            val unblock = _const "Posix_Signal_unblock": how;
-         end
-      
-      structure Process =
-         struct
-            val wnohang = _const "Posix_Process_wnohang": word;
-            structure W =
-               struct
-                  type flags = word
-                  val untraced = _const "Posix_Process_W_untraced": flags;
-               end
-
-            structure Status = Primitive.Status
-            
-            val alarm = _import "Posix_Process_alarm": int -> int;
-            val exece =
-               _import "Posix_Process_exece"
-               : NullString.t * NullString.t array * NullString.t array -> int;
-            val execp =
-               _import "Posix_Process_execp"
-               : NullString.t * NullString.t array -> int;
-            val exit = _import "Posix_Process_exit": int -> unit;
-            val exitStatus = _import "Posix_Process_exitStatus": Status.t -> int;
-            val fork = _import "Posix_Process_fork": unit -> Pid.t;
-            val ifExited = _import "Posix_Process_ifExited": Status.t -> bool;
-            val ifSignaled = _import "Posix_Process_ifSignaled"
-               : Status.t -> bool;
-            val ifStopped = _import "Posix_Process_ifStopped": Status.t -> bool;
-            val kill = _import "Posix_Process_kill": Pid.t * Signal.t -> int;
-            val nanosleep =
-               _import "Posix_Process_nanosleep": int ref * int ref -> int;
-            val pause = _import "Posix_Process_pause": unit -> int;
-(*          val sleep = _import "Posix_Process_sleep": int -> int; *)
-            val stopSig = _import "Posix_Process_stopSig": Status.t -> Signal.t;
-            val system =
-               _import "Posix_Process_system": NullString.t -> Status.t;
-            val termSig = _import "Posix_Process_termSig": Status.t -> Signal.t;
-            val waitpid =
-               _import "Posix_Process_waitpid"
-               : Pid.t * Status.t ref * int -> Pid.t;
-            val cwait =
-               if let
-                     open Primitive.MLton.Platform.OS
-                  in
-                     case host of
-                        Cygwin => true
-                      | MinGW => true
-                      | _ => false
-                  end
-                  then _import "MLton_Process_cwait": Pid.t * Status.t ref -> Pid.t;
-               else fn _ => raise Fail "cwait not defined"
-         end
-
-      structure ProcEnv =
-         struct
-            val numgroups = _const "Posix_ProcEnv_numgroups": int;
-            val sysconfNames =
-               [
-                (* Required *)
-                (_const "Posix_ProcEnv_ARG_MAX": int;, "ARG_MAX"),
-                (_const "Posix_ProcEnv_CHILD_MAX": int;, "CHILD_MAX"),
-                (_const "Posix_ProcEnv_CLK_TCK": int;, "CLK_TCK"),
-                (_const "Posix_ProcEnv_NGROUPS_MAX": int;, "NGROUPS_MAX"),
-                (_const "Posix_ProcEnv_OPEN_MAX": int;, "OPEN_MAX"),
-                (_const "Posix_ProcEnv_STREAM_MAX": int;, "STREAM_MAX"),
-                (_const "Posix_ProcEnv_TZNAME_MAX": int;, "TZNAME_MAX"),
-                (_const "Posix_ProcEnv_JOB_CONTROL": int;, "JOB_CONTROL"),
-                (_const "Posix_ProcEnv_SAVED_IDS": int;, "SAVED_IDS"),
-                (_const "Posix_ProcEnv_VERSION": int;, "VERSION"),
-                (* Optional *)
-                (_const "Posix_ProcEnv_BC_BASE_MAX": int;, "BC_BASE_MAX"),
-                (_const "Posix_ProcEnv_BC_DIM_MAX": int;, "BC_DIM_MAX"),
-                (_const "Posix_ProcEnv_BC_SCALE_MAX": int;, "BC_SCALE_MAX"),
-                (_const "Posix_ProcEnv_BC_STRING_MAX": int;, "BC_STRING_MAX"),
-                (_const "Posix_ProcEnv_COLL_WEIGHTS_MAX": int;,
-                 "COLL_WEIGHTS_MAX"),
-                (_const "Posix_ProcEnv_EXPR_NEST_MAX": int;, "EXPR_NEST_MAX"),
-                (_const "Posix_ProcEnv_LINE_MAX": int;, "LINE_MAX"),
-                (_const "Posix_ProcEnv_RE_DUP_MAX": int;, "RE_DUP_MAX"),
-                (_const "Posix_ProcEnv_2_VERSION": int;, "2_VERSION"),
-                (_const "Posix_ProcEnv_2_FORT_DEV": int;, "2_FORT_DEV"),
-                (_const "Posix_ProcEnv_2_FORT_RUN": int;, "2_FORT_RUN"),
-                (_const "Posix_ProcEnv_2_SW_DEV": int;, "2_SW_DEV")
-                ]
-               
-            type gid = gid
-            type uid = uid
-            type file_desc = file_desc
-
-            val getegid = _import "Posix_ProcEnv_getegid": unit -> gid;
-            val geteuid = _import "Posix_ProcEnv_geteuid": unit -> uid;
-            val getgid = _import "Posix_ProcEnv_getgid": unit -> gid;
-            val getgroups = _import "Posix_ProcEnv_getgroups": gid array -> int;
-            val getlogin = _import "Posix_ProcEnv_getlogin": unit -> cstring;
-            val getpgrp = _import "Posix_ProcEnv_getpgrp": unit -> Pid.t;
-            val getpid = _import "Posix_ProcEnv_getpid": unit -> Pid.t;
-            val getppid = _import "Posix_ProcEnv_getppid": unit -> Pid.t;
-            val getuid = _import "Posix_ProcEnv_getuid": unit -> uid;
-            val setenv =
-               _import "Posix_ProcEnv_setenv": NullString.t * NullString.t -> int;
-            val setgid = _import "Posix_ProcEnv_setgid": gid -> int;
-            val setgroups = _import "Posix_ProcEnv_setgroups": gid array -> int;
-            val setpgid = _import "Posix_ProcEnv_setpgid": Pid.t * Pid.t -> int;
-            val setsid = _import "Posix_ProcEnv_setsid": unit -> Pid.t;
-            val setuid = _import "Posix_ProcEnv_setuid": uid -> int;
-
-            structure Uname =
-               struct
-                  val uname = _import "Posix_ProcEnv_Uname_uname": unit -> int;
-                  val sysname =
-                     _import "Posix_ProcEnv_Uname_sysname": unit -> cstring;
-                  val nodename =
-                     _import "Posix_ProcEnv_Uname_nodename": unit -> cstring;
-                  val release =
-                     _import "Posix_ProcEnv_Uname_release": unit -> cstring;
-                  val version =
-                     _import "Posix_ProcEnv_Uname_version": unit -> cstring;
-                  val machine =
-                     _import "Posix_ProcEnv_Uname_machine": unit -> cstring;
-               end
-
-            type clock_t = word
-               
-            structure Tms =
-               struct
-                  val utime = _import "Posix_ProcEnv_Tms_utime": unit -> clock_t;
-                  val stime = _import "Posix_ProcEnv_Tms_stime": unit -> clock_t;
-                  val cutime = _import "Posix_ProcEnv_Tms_cutime": unit -> clock_t;
-                  val cstime = _import "Posix_ProcEnv_Tms_cstime": unit -> clock_t;
-               end
-
-            val ctermid = _import "Posix_ProcEnv_ctermid": unit -> cstring;
-            val environ = #1 _symbol "Posix_ProcEnv_environ": cstringArray GetSet.t; ()
-            val getenv = _import "Posix_ProcEnv_getenv": NullString.t -> cstring;
-            val isatty = _import "Posix_ProcEnv_isatty": fd -> bool;
-            val sysconf = _import "Posix_ProcEnv_sysconf": int -> int;
-            val times = _import "Posix_ProcEnv_times": unit -> clock_t;
-            val ttyname = _import "Posix_ProcEnv_ttyname": fd -> cstring;
-         end 
-      
-      structure FileSys =
-         struct
-            type file_desc = file_desc
-
-            type ino = int
-            type dev = word
-            type uid = uid
-            type gid = gid
-
-            structure S =
-               struct
-                  type mode = word
-(*                val ifsock = _const "Posix_FileSys_S_ifsock": mode; *)
-(*                val iflnk = _const "Posix_FileSys_S_iflnk": mode; *)
-(*                val ifreg = _const "Posix_FileSys_S_ifreg": mode; *)
-(*                val ifblk = _const "Posix_FileSys_S_ifblk": mode; *)
-(*                val ifdir = _const "Posix_FileSys_S_ifdir": mode; *)
-(*                val ifchr = _const "Posix_FileSys_S_ifchr": mode; *)
-(*                val ififo = _const "Posix_FileSys_S_ififo": mode; *)
-                  val irwxu = _const "Posix_FileSys_S_irwxu": mode;
-                  val irusr = _const "Posix_FileSys_S_irusr": mode;
-                  val iwusr = _const "Posix_FileSys_S_iwusr": mode;
-                  val ixusr = _const "Posix_FileSys_S_ixusr": mode;
-                  val irwxg = _const "Posix_FileSys_S_irwxg": mode;
-                  val irgrp = _const "Posix_FileSys_S_irgrp": mode;
-                  val iwgrp = _const "Posix_FileSys_S_iwgrp": mode;
-                  val ixgrp = _const "Posix_FileSys_S_ixgrp": mode;
-                  val irwxo = _const "Posix_FileSys_S_irwxo": mode;
-                  val iroth = _const "Posix_FileSys_S_iroth": mode;
-                  val iwoth = _const "Posix_FileSys_S_iwoth": mode;
-                  val ixoth = _const "Posix_FileSys_S_ixoth": mode;
-                  val isuid = _const "Posix_FileSys_S_isuid": mode;
-                  val isgid = _const "Posix_FileSys_S_isgid": mode;
-               end
-
-            structure O =
-               struct
-                  type flags = word
-                  val append = _const "Posix_FileSys_O_append": flags;
-                  val creat = _const "Posix_FileSys_O_creat": flags;
-                  val excl = _const "Posix_FileSys_O_excl": flags;
-                  val noctty = _const "Posix_FileSys_O_noctty": flags;
-                  val nonblock = _const "Posix_FileSys_O_nonblock": flags;
-                  val sync = _const "Posix_FileSys_O_sync": flags;
-                  val trunc = _const "Posix_FileSys_O_trunc": flags;
-                  val text = _const "Posix_FileSys_O_text": flags;
-                  val binary = _const "Posix_FileSys_O_binary": flags;
-               end
-
-            val o_rdonly = _const "Posix_FileSys_o_rdonly": word;
-            val o_wronly = _const "Posix_FileSys_o_wronly": word;
-            val o_rdwr = _const "Posix_FileSys_o_rdwr": word;
-            val R_OK = _const "Posix_FileSys_R_OK": word;
-            val W_OK = _const "Posix_FileSys_W_OK": word;
-            val X_OK = _const "Posix_FileSys_X_OK": word;
-            val F_OK = _const "Posix_FileSys_F_OK": word;
-
-            val properties =
-               [
-                (_const "Posix_FileSys_CHOWN_RESTRICTED": int;,
-                 "CHOWN_RESTRICTED"),
-                (_const "Posix_FileSys_LINK_MAX": int;, "LINK_MAX"),
-                (_const "Posix_FileSys_MAX_CANON": int;, "MAX_CANON"),
-                (_const "Posix_FileSys_MAX_INPUT": int;, "MAX_INPUT"),
-                (_const "Posix_FileSys_NAME_MAX": int;, "NAME_MAX"),
-                (_const "Posix_FileSys_NO_TRUNC": int;, "NO_TRUNC"),
-                (_const "Posix_FileSys_PATH_MAX": int;, "PATH_MAX"),
-                (_const "Posix_FileSys_PIPE_BUF": int;, "PIPE_BUF"),
-                (_const "Posix_FileSys_VDISABLE": int;, "VDISABLE"),
-                (_const "Posix_FileSys_ASYNC_IO": int;, "ASYNC_IO"), 
-                (_const "Posix_FileSys_SYNC_IO": int;, "SYNC_IO"), 
-                (_const "Posix_FileSys_PRIO_IO": int;, "PRIO_IO")
-                ]
-
-            structure Dirstream =
-               struct
-                  type dirstream = Pointer.t
-
-                  val closedir =
-                     _import "Posix_FileSys_Dirstream_closedir": dirstream -> int;
-                  val opendir =
-                     _import "Posix_FileSys_Dirstream_opendir"
-                     : NullString.t -> dirstream;
-                  val readdir =
-                     _import "Posix_FileSys_Dirstream_readdir"
-                     : dirstream -> cstring;
-                  val rewinddir =
-                     _import "Posix_FileSys_Dirstream_rewinddir"
-                     : dirstream -> unit;
-               end
-
-            structure Stat =
-               struct
-                  val dev = _import "Posix_FileSys_Stat_dev": unit -> dev;
-                  val ino = _import "Posix_FileSys_Stat_ino": unit -> ino;
-                  val mode = _import "Posix_FileSys_Stat_mode": unit -> word;
-                  val nlink = _import "Posix_FileSys_Stat_nlink": unit -> int;
-                  val uid = _import "Posix_FileSys_Stat_uid": unit -> uid;
-                  val gid = _import "Posix_FileSys_Stat_gid": unit -> gid;
-                  val size =
-                     _import "Posix_FileSys_Stat_size": unit -> Position.int;
-                  val atime =
-                     _import "Posix_FileSys_Stat_atime": unit -> time;
-                  val mtime =
-                     _import "Posix_FileSys_Stat_mtime": unit -> time;
-                  val ctime =
-                     _import "Posix_FileSys_Stat_ctime": unit -> time;
-                  val fstat = _import "Posix_FileSys_Stat_fstat": fd -> int;
-                  val lstat =
-                     _import "Posix_FileSys_Stat_lstat": NullString.t -> int;
-                  val stat =
-                     _import "Posix_FileSys_Stat_stat": NullString.t -> int;
-               end
-
-            structure Utimbuf =
-               struct
-                  val setActime =
-                     _import "Posix_FileSys_Utimbuf_setActime": time -> unit;
-                  val setModtime =
-                     _import "Posix_FileSys_Utimbuf_setModTime": time -> unit;
-                  val utime =
-                     _import "Posix_FileSys_Utimbuf_utime": NullString.t -> int;
-               end
-
-            val access =
-               _import "Posix_FileSys_access": NullString.t * word -> int;
-            val chdir = _import "Posix_FileSys_chdir": NullString.t -> int;
-            val chmod =
-               _import "Posix_FileSys_chmod": NullString.t * mode -> int;
-            val chown =
-               _import "Posix_FileSys_chown": NullString.t * uid * gid -> int;
-            val fchmod =
-               _import "Posix_FileSys_fchmod": fd * mode -> int;
-            val fchown =
-               _import "Posix_FileSys_fchown": fd * uid * gid -> int;
-            val fpathconf =
-               _import "Posix_FileSys_fpathconf": fd * int -> int;
-            val ftruncate =
-               _import "Posix_FileSys_ftruncate": fd * Position.int -> int;
-            val getcwd =
-               _import "Posix_FileSys_getcwd": char array * size -> cstring;
-            val link =
-               _import "Posix_FileSys_link": NullString.t * NullString.t -> int;
-            val mkdir =
-               _import "Posix_FileSys_mkdir": NullString.t * word -> int;
-            val mkfifo =
-               _import "Posix_FileSys_mkfifo": NullString.t * word -> int;
-            val openn =
-               _import "Posix_FileSys_open": NullString.t * word * mode -> int;
-            val pathconf =
-               _import "Posix_FileSys_pathconf": NullString.t * int -> int;
-            val readlink =
-               _import "Posix_FileSys_readlink"
-               : NullString.t * word8 array * int -> int;
-            val rename =
-               _import "Posix_FileSys_rename": NullString.t * NullString.t -> int;
-            val rmdir = _import "Posix_FileSys_rmdir": NullString.t -> int;
-            val symlink =
-               _import "Posix_FileSys_symlink"
-               : NullString.t * NullString.t -> int;
-            val umask = _import "Posix_FileSys_umask": word -> word;
-            val unlink = _import "Posix_FileSys_unlink": NullString.t -> int;
-
-            structure ST =
-               struct
-                  val isDir = _import "Posix_FileSys_ST_isDir": word -> bool;
-                  val isChr = _import "Posix_FileSys_ST_isChr": word -> bool;
-                  val isBlk = _import "Posix_FileSys_ST_isBlk": word -> bool;
-                  val isReg = _import "Posix_FileSys_ST_isReg": word -> bool;
-                  val isFIFO =
-                     _import "Posix_FileSys_ST_isFIFO": word -> bool;
-                  val isLink =
-                     _import "Posix_FileSys_ST_isLink": word -> bool;
-                  val isSock =
-                     _import "Posix_FileSys_ST_isSock": word -> bool;
-               end
-         end
-
-      structure IO =
-         struct
-            val F_DUPFD = _const "Posix_IO_F_DUPFD": int;
-            val F_GETFD = _const "Posix_IO_F_GETFD": int;
-            val F_SETFD = _const "Posix_IO_F_SETFD": int;
-            val F_GETFL = _const "Posix_IO_F_GETFL": int;
-            val F_SETFL = _const "Posix_IO_F_SETFL": int;
-            val F_GETLK = _const "Posix_IO_F_GETLK": int;
-            val F_SETLK = _const "Posix_IO_F_SETLK": int;
-            val F_RDLCK = _const "Posix_IO_F_RDLCK": int;
-            val F_WRLCK = _const "Posix_IO_F_WRLCK": int;
-            val F_UNLCK = _const "Posix_IO_F_UNLCK": int;
-            val F_SETLKW = _const "Posix_IO_F_SETLKW": int;
-(*          val F_GETOWN = _const "Posix_IO_F_GETOWN": int; *)
-(*          val F_SETOWN = _const "Posix_IO_F_SETOWN": int; *)
-            val O_ACCMODE = _const "Posix_IO_O_ACCMODE": word;
-            val SEEK_SET = _const "Posix_IO_SEEK_SET": int;
-            val SEEK_CUR = _const "Posix_IO_SEEK_CUR": int;
-            val SEEK_END = _const "Posix_IO_SEEK_END": int;
-
-            structure FD =
-               struct
-                  type flags = word
-                  val cloexec = _const "Posix_IO_FD_cloexec": flags;
-               end
-            
-            type file_desc = file_desc
-
-            structure FLock =
-               struct
-                  val fcntl = _import "Posix_IO_FLock_fcntl": fd * int -> int;
-                  val typ = _import "Posix_IO_FLock_type": unit -> int;
-                  val whence = _import "Posix_IO_FLock_whence": unit -> int;
-                  val start =
-                     _import "Posix_IO_FLock_start": unit -> Position.int;
-                  val len =
-                     _import "Posix_IO_FLock_len": unit -> Position.int;
-                  val pid = _import "Posix_IO_FLock_pid": unit -> Pid.t;
-                  val setType = _import "Posix_IO_FLock_setType": int -> unit;
-                  val setWhence =
-                     _import "Posix_IO_FLock_setWhence": int -> unit;
-                  val setStart =
-                     _import "Posix_IO_FLock_setStart": Position.int -> unit;
-                  val setLen =
-                     _import "Posix_IO_FLock_setLen": Position.int -> unit;
-(*                val setPid = _import "Posix_IO_FLock_setPid": Pid.t -> unit; *)
-               end
-            
-            val close = _import "Posix_IO_close": fd -> int;
-            val dup = _import "Posix_IO_dup": fd -> int;
-            val dup2 = _import "Posix_IO_dup2": fd * fd -> int;
-            val fcntl2 = _import "Posix_IO_fcntl2": fd * int -> int;
-            val fcntl3 = _import "Posix_IO_fcntl3": fd * int * int -> int;
-            val fsync = _import "Posix_IO_fsync": fd -> int;
-            val lseek =
-               _import "Posix_IO_lseek": fd * Position.int * int -> Position.int;
-            val pipe = _import "Posix_IO_pipe": fd array -> int;
-            val readChar =
-               _import "Posix_IO_read": fd * char array * int * size -> ssize;
-            val setbin = 
-               if let
-                     open Primitive.MLton.Platform.OS
-                  in
-                     case host of
-                        MinGW => true
-                      | _ => false
-                  end
-                  then _import "Posix_IO_setbin": fd -> unit;
-               else fn _ => raise Fail "setbin not defined"
-            val settext = 
-               if let
-                     open Primitive.MLton.Platform.OS
-                  in
-                     case host of
-                        MinGW => true
-                      | _ => false
-                  end
-                  then _import "Posix_IO_settext": fd -> unit;
-               else fn _ => raise Fail "settext not defined"
-            val writeChar =
-               _import "Posix_IO_write": fd * char array * int * size -> ssize;
-            val writeCharVec =
-               _import "Posix_IO_write": fd * char vector * int * size -> ssize;
-            val readWord8 =
-               _import "Posix_IO_read": fd * word8 array * int * size -> ssize;
-            val writeWord8 =
-               _import "Posix_IO_write": fd * word8 array * int * size -> ssize;
-            val writeWord8Vec =
-               _import "Posix_IO_write": fd * word8 vector * int * size -> ssize;
-         end           
-
-      structure SysDB =
-         struct
-            type gid = gid
-            type uid = uid
-
-            structure Passwd =
-               struct
-                  val name = _import "Posix_SysDB_Passwd_name": unit -> cstring;
-                  val uid = _import "Posix_SysDB_Passwd_uid": unit -> uid;
-                  val gid = _import "Posix_SysDB_Passwd_gid": unit -> gid;
-                  val dir = _import "Posix_SysDB_Passwd_dir": unit -> cstring;
-                  val shell =
-                     _import "Posix_SysDB_Passwd_shell": unit -> cstring;
-               end
-
-            val getpwnam = _import "Posix_SysDB_getpwnam": NullString.t -> bool;
-            val getpwuid = _import "Posix_SysDB_getpwuid": uid -> bool;
-
-            structure Group =
-               struct
-                  val name = _import "Posix_SysDB_Group_name": unit -> cstring;
-                  val gid = _import "Posix_SysDB_Group_gid": unit -> gid;
-                  val mem =
-                     _import "Posix_SysDB_Group_mem": unit -> cstringArray;
-               end
-
-            val getgrgid = _import "Posix_SysDB_getgrgid": gid -> bool;
-            val getgrnam = _import "Posix_SysDB_getgrnam": NullString.t -> bool;
-         end
-
-      structure TTY =
-         struct
-            type speed = word
-            val b0 = _const "Posix_TTY_b0": speed;
-            val b110 = _const "Posix_TTY_b110": speed;
-            val b1200 = _const "Posix_TTY_b1200": speed;
-            val b134 = _const "Posix_TTY_b134": speed;
-            val b150 = _const "Posix_TTY_b150": speed;
-            val b1800 = _const "Posix_TTY_b1800": speed;
-            val b19200 = _const "Posix_TTY_b19200": speed;
-            val b200 = _const "Posix_TTY_b200": speed;
-            val b2400 = _const "Posix_TTY_b2400": speed;
-            val b300 = _const "Posix_TTY_b300": speed;
-            val b38400 = _const "Posix_TTY_b38400": speed;
-            val b4800 = _const "Posix_TTY_b4800": speed;
-            val b50 = _const "Posix_TTY_b50": speed;
-            val b600 = _const "Posix_TTY_b600": speed;
-            val b75 = _const "Posix_TTY_b75": speed;
-            val b9600 = _const "Posix_TTY_b9600": speed;
-               
-            type file_desc = file_desc
-
-            structure V =
-               struct
-                  val eof = _const "Posix_TTY_V_eof": int;
-                  val eol = _const "Posix_TTY_V_eol": int;
-                  val erase = _const "Posix_TTY_V_erase": int;
-                  val intr = _const "Posix_TTY_V_intr": int;
-                  val kill = _const "Posix_TTY_V_kill": int;
-                  val min = _const "Posix_TTY_V_min": int;
-                  val nccs = _const "Posix_TTY_V_nccs": int;
-                  val quit = _const "Posix_TTY_V_quit": int;
-                  val start = _const "Posix_TTY_V_start": int;
-                  val stop = _const "Posix_TTY_V_stop": int;
-                  val susp = _const "Posix_TTY_V_susp": int;
-                  val time = _const "Posix_TTY_V_time": int;
-               end
-
-            structure I =
-               struct
-                  type flags = word
-                  val brkint = _const "Posix_TTY_I_brkint": flags;
-                  val icrnl = _const "Posix_TTY_I_icrnl": flags;
-                  val ignbrk = _const "Posix_TTY_I_ignbrk": flags;
-                  val igncr = _const "Posix_TTY_I_igncr": flags;
-                  val ignpar = _const "Posix_TTY_I_ignpar": flags;
-                  val inlcr = _const "Posix_TTY_I_inlcr": flags;
-                  val inpck = _const "Posix_TTY_I_inpck": flags;
-                  val istrip = _const "Posix_TTY_I_istrip": flags;
-                  val ixoff = _const "Posix_TTY_I_ixoff": flags;
-                  val ixon = _const "Posix_TTY_I_ixon": flags;
-                  val parmrk = _const "Posix_TTY_I_parmrk": flags;
-               end
-
-            structure O =
-               struct
-                  type flags = word
-                  val opost = _const "Posix_TTY_O_opost": flags;
-               end
-
-            structure C =
-               struct
-                  type flags = word
-                  val clocal = _const "Posix_TTY_C_clocal": flags;
-                  val cread = _const "Posix_TTY_C_cread": flags;
-                  val cs5 = _const "Posix_TTY_C_cs5": flags;
-                  val cs6 = _const "Posix_TTY_C_cs6": flags;
-                  val cs7 = _const "Posix_TTY_C_cs7": flags;
-                  val cs8 = _const "Posix_TTY_C_cs8": flags;
-                  val csize = _const "Posix_TTY_C_csize": flags;
-                  val cstopb = _const "Posix_TTY_C_cstopb": flags;
-                  val hupcl = _const "Posix_TTY_C_hupcl": flags;
-                  val parenb = _const "Posix_TTY_C_parenb": flags;
-                  val parodd = _const "Posix_TTY_C_parodd": flags;
-               end
-
-            structure L =
-               struct
-                  type flags = word
-                  val echo = _const "Posix_TTY_L_echo": flags;
-                  val echoe = _const "Posix_TTY_L_echoe": flags;
-                  val echok = _const "Posix_TTY_L_echok": flags;
-                  val echonl = _const "Posix_TTY_L_echonl": flags;
-                  val icanon = _const "Posix_TTY_L_icanon": flags;
-                  val iexten = _const "Posix_TTY_L_iexten": flags;
-                  val isig = _const "Posix_TTY_L_isig": flags;
-                  val noflsh = _const "Posix_TTY_L_noflsh": flags;
-                  val tostop = _const "Posix_TTY_L_tostop": flags;
-               end
-
-            structure TC =
-               struct
-                  type set_action = int
-
-                  val sadrain = _const "Posix_TTY_TC_sadrain": set_action;
-                  val saflush = _const "Posix_TTY_TC_saflush": set_action;
-                  val sanow = _const "Posix_TTY_TC_sanow": set_action;
-
-                  type flow_action = int
-
-                  val ion = _const "Posix_TTY_TC_ion": flow_action;
-                  val ioff = _const "Posix_TTY_TC_ioff": flow_action;
-                  val ooff = _const "Posix_TTY_TC_ooff": flow_action;
-                  val oon = _const "Posix_TTY_TC_oon": flow_action;
-
-                  type queue_sel = int
-
-                  val iflush = _const "Posix_TTY_TC_iflush": queue_sel;
-                  val ioflush = _const "Posix_TTY_TC_ioflush": queue_sel;
-                  val oflush = _const "Posix_TTY_TC_oflush": queue_sel;
-               end                
-
-            structure Termios =
-               struct
-                  type flag = word
-
-                  val iflag = _import "Posix_TTY_Termios_iflag": unit -> flag;
-                  val oflag = _import "Posix_TTY_Termios_oflag": unit -> flag;
-                  val cflag = _import "Posix_TTY_Termios_cflag": unit -> flag;
-                  val lflag = _import "Posix_TTY_Termios_lflag": unit -> flag;
-                  val cc = _import "Posix_TTY_Termios_cc": unit -> cstring;
-                  val ospeed =
-                     _import "Posix_TTY_Termios_cfgetospeed": unit -> speed;
-                  val ispeed =
-                     _import "Posix_TTY_Termios_cfgetispeed": unit -> speed;
-                  val setiflag =
-                     _import "Posix_TTY_Termios_setiflag": flag -> unit;
-                  val setoflag =
-                     _import "Posix_TTY_Termios_setoflag": flag -> unit;
-                  val setcflag =
-                     _import "Posix_TTY_Termios_setcflag": flag -> unit;
-                  val setlflag =
-                     _import "Posix_TTY_Termios_setlflag": flag -> unit;
-                  val setospeed =
-                     _import "Posix_TTY_Termios_setospeed": speed -> int;
-                  val setispeed =
-                     _import "Posix_TTY_Termios_setispeed": speed -> int;
-               end
-
-            val drain = _import "Posix_TTY_drain": fd -> int;
-            val flow = _import "Posix_TTY_flow": fd * TC.flow_action -> int;
-            val flush = _import "Posix_TTY_flush": fd * TC.queue_sel -> int;
-            val getattr = _import "Posix_TTY_getattr": fd -> int;
-            val getpgrp = _import "Posix_TTY_getpgrp": fd -> Pid.t;
-            val sendbreak = _import "Posix_TTY_sendbreak": fd * int -> int;
-            val setattr = _import "Posix_TTY_setattr": fd * TC.set_action -> int;
-            val setpgrp = _import "Posix_TTY_setpgrp": fd * Pid.t -> int;
-         end
-   end

Copied: mlton/branches/on-20050822-x86_64-branch/basis-library/primitive/posix-primitive.sml (from rev 4323, mlton/branches/on-20050822-x86_64-branch/basis-library/posix/primitive.sml)
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library/posix/primitive.sml	2006-01-28 17:09:17 UTC (rev 4323)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/primitive/posix-primitive.sml	2006-01-28 17:54:57 UTC (rev 4324)
@@ -0,0 +1,758 @@
+(* 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.
+ *)
+
+structure PosixPrimitive =
+   struct
+      type cstring = Pointer.t
+      type cstringArray = Pointer.t
+
+      type uid = word
+      type gid = word
+      type size = int
+      type ssize = int
+      type mode = word
+      type time = int
+
+      structure FileDesc = Primitive.FileDesc
+      type file_desc = FileDesc.t
+      type fd = file_desc
+         
+      structure Error =
+         struct
+            type syserror = int
+
+            val getErrno = _import "Posix_Error_getErrno": unit -> int;
+            val clearErrno = _import "Posix_Error_clearErrno": unit -> unit;
+            val strerror = _import "Posix_Error_strerror": syserror -> cstring;
+
+            val acces = _const "Posix_Error_acces": syserror;
+            val again = _const "Posix_Error_again": syserror;
+            val badf = _const "Posix_Error_badf": syserror;
+            val badmsg = _const "Posix_Error_badmsg": syserror;
+            val busy = _const "Posix_Error_busy": syserror;
+            val canceled = _const "Posix_Error_canceled": syserror;
+            val child = _const "Posix_Error_child": syserror;
+            val deadlk = _const "Posix_Error_deadlk": syserror;
+            val dom = _const "Posix_Error_dom": syserror;
+            val exist = _const "Posix_Error_exist": syserror;
+            val fault = _const "Posix_Error_fault": syserror;
+            val fbig = _const "Posix_Error_fbig": syserror;
+            val inprogress = _const "Posix_Error_inprogress": syserror;
+            val intr = _const "Posix_Error_intr": syserror;
+            val inval = _const "Posix_Error_inval": syserror;
+            val io = _const "Posix_Error_io": syserror;
+            val isdir = _const "Posix_Error_isdir": syserror;
+            val loop = _const "Posix_Error_loop": syserror;
+            val mfile = _const "Posix_Error_mfile": syserror;
+            val mlink = _const "Posix_Error_mlink": syserror;
+            val msgsize = _const "Posix_Error_msgsize": syserror;
+            val nametoolong = _const "Posix_Error_nametoolong": syserror;
+            val nfile = _const "Posix_Error_nfile": syserror;
+            val nodev = _const "Posix_Error_nodev": syserror;
+            val noent = _const "Posix_Error_noent": syserror;
+            val noexec = _const "Posix_Error_noexec": syserror;
+            val nolck = _const "Posix_Error_nolck": syserror;
+            val nomem = _const "Posix_Error_nomem": syserror;
+            val nospc = _const "Posix_Error_nospc": syserror;
+            val nosys = _const "Posix_Error_nosys": syserror;
+            val notdir = _const "Posix_Error_notdir": syserror;
+            val notempty = _const "Posix_Error_notempty": syserror;
+            val notsup = _const "Posix_Error_notsup": syserror;
+            val notty = _const "Posix_Error_notty": syserror;
+            val nxio = _const "Posix_Error_nxio": syserror;
+            val perm = _const "Posix_Error_perm": syserror;
+            val pipe = _const "Posix_Error_pipe": syserror;
+            val range = _const "Posix_Error_range": syserror;
+            val rofs = _const "Posix_Error_rofs": syserror;
+            val spipe = _const "Posix_Error_spipe": syserror;
+            val srch = _const "Posix_Error_srch": syserror;
+            val toobig = _const "Posix_Error_toobig": syserror;
+            val xdev = _const "Posix_Error_xdev": syserror;
+
+            val errorNames =
+               [
+                (acces, "acces"),
+                (again, "again"),
+                (badf, "badf"),
+                (badmsg, "badmsg"),
+                (busy, "busy"),
+                (canceled, "canceled"),
+                (child, "child"),
+                (deadlk, "deadlk"),
+                (dom, "dom"),
+                (exist, "exist"),
+                (fault, "fault"),
+                (fbig, "fbig"),
+                (inprogress, "inprogress"),
+                (intr, "intr"),
+                (inval, "inval"),
+                (io, "io"),
+                (isdir, "isdir"),
+                (loop, "loop"),
+                (mfile, "mfile"),
+                (mlink, "mlink"),
+                (msgsize, "msgsize"),
+                (nametoolong, "nametoolong"),
+                (nfile, "nfile"),
+                (nodev, "nodev"),
+                (noent, "noent"),
+                (noexec, "noexec"),
+                (nolck, "nolck"),
+                (nomem, "nomem"),
+                (nospc, "nospc"),
+                (nosys, "nosys"),
+                (notdir, "notdir"),
+                (notempty, "notempty"),
+                (notsup, "notsup"),
+                (notty, "notty"),
+                (nxio, "nxio"),
+                (perm, "perm"),
+                (pipe, "pipe"),
+                (range, "range"),
+                (rofs, "rofs"),
+                (spipe, "spipe"),
+                (srch, "srch"),
+                (toobig, "toobig"),
+                (xdev, "xdev")
+                ]
+         end
+      
+      structure Signal =
+         struct
+            open Primitive.Signal
+               
+            val abrt = _const "Posix_Signal_abrt": t;
+            val alrm = _const "Posix_Signal_alrm": t;
+            val bus = _const "Posix_Signal_bus": t;
+            val chld = _const "Posix_Signal_chld": t;
+            val cont = _const "Posix_Signal_cont": t;
+            val fpe = _const "Posix_Signal_fpe": t;
+            val hup = _const "Posix_Signal_hup": t;
+            val ill = _const "Posix_Signal_ill": t;
+            val int = _const "Posix_Signal_int": t;
+            val kill = _const "Posix_Signal_kill": t;
+            val pipe = _const "Posix_Signal_pipe": t;
+            val prof = _const "Posix_Signal_prof": t;
+            val quit = _const "Posix_Signal_quit": t;
+            val segv = _const "Posix_Signal_segv": t;
+            val stop = _const "Posix_Signal_stop": t;
+            val term = _const "Posix_Signal_term": t;
+            val tstp = _const "Posix_Signal_tstp": t;
+            val ttin = _const "Posix_Signal_ttin": t;
+            val ttou = _const "Posix_Signal_ttou": t;
+            val usr1 = _const "Posix_Signal_usr1": t;
+            val usr2 = _const "Posix_Signal_usr2": t;
+            val vtalrm = _const "Posix_Signal_vtalrm": t;
+
+            val block = _const "Posix_Signal_block": how;
+            val default = _import "Posix_Signal_default": t -> int;
+            val handleGC = _import "Posix_Signal_handleGC": unit -> unit;
+            val handlee = _import "Posix_Signal_handle": t -> int;
+            val ignore = _import "Posix_Signal_ignore": t -> int;
+            val isDefault =
+               _import "Posix_Signal_isDefault": t * bool ref -> int;
+            val isGCPending = _import "Posix_Signal_isGCPending": unit -> bool;
+            val isPending = _import "Posix_Signal_isPending": t -> bool;
+            val numSignals = _const "Posix_Signal_numSignals": int;
+            val resetPending = _import "Posix_Signal_resetPending": unit -> unit;
+            val setmask = _const "Posix_Signal_setmask": how;
+            val sigaddset = _import "Posix_Signal_sigaddset": t -> int;
+            val sigdelset = _import "Posix_Signal_sigdelset": t -> int;
+            val sigemptyset = _import "Posix_Signal_sigemptyset": unit -> int;
+            val sigfillset = _import "Posix_Signal_sigfillset": unit -> int;
+            val sigismember = _import "Posix_Signal_sigismember": t -> int;
+            val sigprocmask = _import "Posix_Signal_sigprocmask": how -> int;
+            val suspend = _import "Posix_Signal_suspend": unit -> unit;
+            val unblock = _const "Posix_Signal_unblock": how;
+         end
+      
+      structure Process =
+         struct
+            val wnohang = _const "Posix_Process_wnohang": word;
+            structure W =
+               struct
+                  type flags = word
+                  val untraced = _const "Posix_Process_W_untraced": flags;
+               end
+
+            structure Status = Primitive.Status
+            
+            val alarm = _import "Posix_Process_alarm": int -> int;
+            val exece =
+               _import "Posix_Process_exece"
+               : NullString.t * NullString.t array * NullString.t array -> int;
+            val execp =
+               _import "Posix_Process_execp"
+               : NullString.t * NullString.t array -> int;
+            val exit = _import "Posix_Process_exit": int -> unit;
+            val exitStatus = _import "Posix_Process_exitStatus": Status.t -> int;
+            val fork = _import "Posix_Process_fork": unit -> Pid.t;
+            val ifExited = _import "Posix_Process_ifExited": Status.t -> bool;
+            val ifSignaled = _import "Posix_Process_ifSignaled"
+               : Status.t -> bool;
+            val ifStopped = _import "Posix_Process_ifStopped": Status.t -> bool;
+            val kill = _import "Posix_Process_kill": Pid.t * Signal.t -> int;
+            val nanosleep =
+               _import "Posix_Process_nanosleep": int ref * int ref -> int;
+            val pause = _import "Posix_Process_pause": unit -> int;
+(*          val sleep = _import "Posix_Process_sleep": int -> int; *)
+            val stopSig = _import "Posix_Process_stopSig": Status.t -> Signal.t;
+            val system =
+               _import "Posix_Process_system": NullString.t -> Status.t;
+            val termSig = _import "Posix_Process_termSig": Status.t -> Signal.t;
+            val waitpid =
+               _import "Posix_Process_waitpid"
+               : Pid.t * Status.t ref * int -> Pid.t;
+            val cwait =
+               if let
+                     open Primitive.MLton.Platform.OS
+                  in
+                     case host of
+                        Cygwin => true
+                      | MinGW => true
+                      | _ => false
+                  end
+                  then _import "MLton_Process_cwait": Pid.t * Status.t ref -> Pid.t;
+               else fn _ => raise Fail "cwait not defined"
+         end
+
+      structure ProcEnv =
+         struct
+            val numgroups = _const "Posix_ProcEnv_numgroups": int;
+            val sysconfNames =
+               [
+                (* Required *)
+                (_const "Posix_ProcEnv_ARG_MAX": int;, "ARG_MAX"),
+                (_const "Posix_ProcEnv_CHILD_MAX": int;, "CHILD_MAX"),
+                (_const "Posix_ProcEnv_CLK_TCK": int;, "CLK_TCK"),
+                (_const "Posix_ProcEnv_NGROUPS_MAX": int;, "NGROUPS_MAX"),
+                (_const "Posix_ProcEnv_OPEN_MAX": int;, "OPEN_MAX"),
+                (_const "Posix_ProcEnv_STREAM_MAX": int;, "STREAM_MAX"),
+                (_const "Posix_ProcEnv_TZNAME_MAX": int;, "TZNAME_MAX"),
+                (_const "Posix_ProcEnv_JOB_CONTROL": int;, "JOB_CONTROL"),
+                (_const "Posix_ProcEnv_SAVED_IDS": int;, "SAVED_IDS"),
+                (_const "Posix_ProcEnv_VERSION": int;, "VERSION"),
+                (* Optional *)
+                (_const "Posix_ProcEnv_BC_BASE_MAX": int;, "BC_BASE_MAX"),
+                (_const "Posix_ProcEnv_BC_DIM_MAX": int;, "BC_DIM_MAX"),
+                (_const "Posix_ProcEnv_BC_SCALE_MAX": int;, "BC_SCALE_MAX"),
+                (_const "Posix_ProcEnv_BC_STRING_MAX": int;, "BC_STRING_MAX"),
+                (_const "Posix_ProcEnv_COLL_WEIGHTS_MAX": int;,
+                 "COLL_WEIGHTS_MAX"),
+                (_const "Posix_ProcEnv_EXPR_NEST_MAX": int;, "EXPR_NEST_MAX"),
+                (_const "Posix_ProcEnv_LINE_MAX": int;, "LINE_MAX"),
+                (_const "Posix_ProcEnv_RE_DUP_MAX": int;, "RE_DUP_MAX"),
+                (_const "Posix_ProcEnv_2_VERSION": int;, "2_VERSION"),
+                (_const "Posix_ProcEnv_2_FORT_DEV": int;, "2_FORT_DEV"),
+                (_const "Posix_ProcEnv_2_FORT_RUN": int;, "2_FORT_RUN"),
+                (_const "Posix_ProcEnv_2_SW_DEV": int;, "2_SW_DEV")
+                ]
+               
+            type gid = gid
+            type uid = uid
+            type file_desc = file_desc
+
+            val getegid = _import "Posix_ProcEnv_getegid": unit -> gid;
+            val geteuid = _import "Posix_ProcEnv_geteuid": unit -> uid;
+            val getgid = _import "Posix_ProcEnv_getgid": unit -> gid;
+            val getgroups = _import "Posix_ProcEnv_getgroups": gid array -> int;
+            val getlogin = _import "Posix_ProcEnv_getlogin": unit -> cstring;
+            val getpgrp = _import "Posix_ProcEnv_getpgrp": unit -> Pid.t;
+            val getpid = _import "Posix_ProcEnv_getpid": unit -> Pid.t;
+            val getppid = _import "Posix_ProcEnv_getppid": unit -> Pid.t;
+            val getuid = _import "Posix_ProcEnv_getuid": unit -> uid;
+            val setenv =
+               _import "Posix_ProcEnv_setenv": NullString.t * NullString.t -> int;
+            val setgid = _import "Posix_ProcEnv_setgid": gid -> int;
+            val setgroups = _import "Posix_ProcEnv_setgroups": gid array -> int;
+            val setpgid = _import "Posix_ProcEnv_setpgid": Pid.t * Pid.t -> int;
+            val setsid = _import "Posix_ProcEnv_setsid": unit -> Pid.t;
+            val setuid = _import "Posix_ProcEnv_setuid": uid -> int;
+
+            structure Uname =
+               struct
+                  val uname = _import "Posix_ProcEnv_Uname_uname": unit -> int;
+                  val sysname =
+                     _import "Posix_ProcEnv_Uname_sysname": unit -> cstring;
+                  val nodename =
+                     _import "Posix_ProcEnv_Uname_nodename": unit -> cstring;
+                  val release =
+                     _import "Posix_ProcEnv_Uname_release": unit -> cstring;
+                  val version =
+                     _import "Posix_ProcEnv_Uname_version": unit -> cstring;
+                  val machine =
+                     _import "Posix_ProcEnv_Uname_machine": unit -> cstring;
+               end
+
+            type clock_t = word
+               
+            structure Tms =
+               struct
+                  val utime = _import "Posix_ProcEnv_Tms_utime": unit -> clock_t;
+                  val stime = _import "Posix_ProcEnv_Tms_stime": unit -> clock_t;
+                  val cutime = _import "Posix_ProcEnv_Tms_cutime": unit -> clock_t;
+                  val cstime = _import "Posix_ProcEnv_Tms_cstime": unit -> clock_t;
+               end
+
+            val ctermid = _import "Posix_ProcEnv_ctermid": unit -> cstring;
+            val environ = #1 _symbol "Posix_ProcEnv_environ": cstringArray GetSet.t; ()
+            val getenv = _import "Posix_ProcEnv_getenv": NullString.t -> cstring;
+            val isatty = _import "Posix_ProcEnv_isatty": fd -> bool;
+            val sysconf = _import "Posix_ProcEnv_sysconf": int -> int;
+            val times = _import "Posix_ProcEnv_times": unit -> clock_t;
+            val ttyname = _import "Posix_ProcEnv_ttyname": fd -> cstring;
+         end 
+      
+      structure FileSys =
+         struct
+            type file_desc = file_desc
+
+            type ino = int
+            type dev = word
+            type uid = uid
+            type gid = gid
+
+            structure S =
+               struct
+                  type mode = word
+(*                val ifsock = _const "Posix_FileSys_S_ifsock": mode; *)
+(*                val iflnk = _const "Posix_FileSys_S_iflnk": mode; *)
+(*                val ifreg = _const "Posix_FileSys_S_ifreg": mode; *)
+(*                val ifblk = _const "Posix_FileSys_S_ifblk": mode; *)
+(*                val ifdir = _const "Posix_FileSys_S_ifdir": mode; *)
+(*                val ifchr = _const "Posix_FileSys_S_ifchr": mode; *)
+(*                val ififo = _const "Posix_FileSys_S_ififo": mode; *)
+                  val irwxu = _const "Posix_FileSys_S_irwxu": mode;
+                  val irusr = _const "Posix_FileSys_S_irusr": mode;
+                  val iwusr = _const "Posix_FileSys_S_iwusr": mode;
+                  val ixusr = _const "Posix_FileSys_S_ixusr": mode;
+                  val irwxg = _const "Posix_FileSys_S_irwxg": mode;
+                  val irgrp = _const "Posix_FileSys_S_irgrp": mode;
+                  val iwgrp = _const "Posix_FileSys_S_iwgrp": mode;
+                  val ixgrp = _const "Posix_FileSys_S_ixgrp": mode;
+                  val irwxo = _const "Posix_FileSys_S_irwxo": mode;
+                  val iroth = _const "Posix_FileSys_S_iroth": mode;
+                  val iwoth = _const "Posix_FileSys_S_iwoth": mode;
+                  val ixoth = _const "Posix_FileSys_S_ixoth": mode;
+                  val isuid = _const "Posix_FileSys_S_isuid": mode;
+                  val isgid = _const "Posix_FileSys_S_isgid": mode;
+               end
+
+            structure O =
+               struct
+                  type flags = word
+                  val append = _const "Posix_FileSys_O_append": flags;
+                  val creat = _const "Posix_FileSys_O_creat": flags;
+                  val excl = _const "Posix_FileSys_O_excl": flags;
+                  val noctty = _const "Posix_FileSys_O_noctty": flags;
+                  val nonblock = _const "Posix_FileSys_O_nonblock": flags;
+                  val sync = _const "Posix_FileSys_O_sync": flags;
+                  val trunc = _const "Posix_FileSys_O_trunc": flags;
+                  val text = _const "Posix_FileSys_O_text": flags;
+                  val binary = _const "Posix_FileSys_O_binary": flags;
+               end
+
+            val o_rdonly = _const "Posix_FileSys_o_rdonly": word;
+            val o_wronly = _const "Posix_FileSys_o_wronly": word;
+            val o_rdwr = _const "Posix_FileSys_o_rdwr": word;
+            val R_OK = _const "Posix_FileSys_R_OK": word;
+            val W_OK = _const "Posix_FileSys_W_OK": word;
+            val X_OK = _const "Posix_FileSys_X_OK": word;
+            val F_OK = _const "Posix_FileSys_F_OK": word;
+
+            val properties =
+               [
+                (_const "Posix_FileSys_CHOWN_RESTRICTED": int;,
+                 "CHOWN_RESTRICTED"),
+                (_const "Posix_FileSys_LINK_MAX": int;, "LINK_MAX"),
+                (_const "Posix_FileSys_MAX_CANON": int;, "MAX_CANON"),
+                (_const "Posix_FileSys_MAX_INPUT": int;, "MAX_INPUT"),
+                (_const "Posix_FileSys_NAME_MAX": int;, "NAME_MAX"),
+                (_const "Posix_FileSys_NO_TRUNC": int;, "NO_TRUNC"),
+                (_const "Posix_FileSys_PATH_MAX": int;, "PATH_MAX"),
+                (_const "Posix_FileSys_PIPE_BUF": int;, "PIPE_BUF"),
+                (_const "Posix_FileSys_VDISABLE": int;, "VDISABLE"),
+                (_const "Posix_FileSys_ASYNC_IO": int;, "ASYNC_IO"), 
+                (_const "Posix_FileSys_SYNC_IO": int;, "SYNC_IO"), 
+                (_const "Posix_FileSys_PRIO_IO": int;, "PRIO_IO")
+                ]
+
+            structure Dirstream =
+               struct
+                  type dirstream = Pointer.t
+
+                  val closedir =
+                     _import "Posix_FileSys_Dirstream_closedir": dirstream -> int;
+                  val opendir =
+                     _import "Posix_FileSys_Dirstream_opendir"
+                     : NullString.t -> dirstream;
+                  val readdir =
+                     _import "Posix_FileSys_Dirstream_readdir"
+                     : dirstream -> cstring;
+                  val rewinddir =
+                     _import "Posix_FileSys_Dirstream_rewinddir"
+                     : dirstream -> unit;
+               end
+
+            structure Stat =
+               struct
+                  val dev = _import "Posix_FileSys_Stat_dev": unit -> dev;
+                  val ino = _import "Posix_FileSys_Stat_ino": unit -> ino;
+                  val mode = _import "Posix_FileSys_Stat_mode": unit -> word;
+                  val nlink = _import "Posix_FileSys_Stat_nlink": unit -> int;
+                  val uid = _import "Posix_FileSys_Stat_uid": unit -> uid;
+                  val gid = _import "Posix_FileSys_Stat_gid": unit -> gid;
+                  val size =
+                     _import "Posix_FileSys_Stat_size": unit -> Position.int;
+                  val atime =
+                     _import "Posix_FileSys_Stat_atime": unit -> time;
+                  val mtime =
+                     _import "Posix_FileSys_Stat_mtime": unit -> time;
+                  val ctime =
+                     _import "Posix_FileSys_Stat_ctime": unit -> time;
+                  val fstat = _import "Posix_FileSys_Stat_fstat": fd -> int;
+                  val lstat =
+                     _import "Posix_FileSys_Stat_lstat": NullString.t -> int;
+                  val stat =
+                     _import "Posix_FileSys_Stat_stat": NullString.t -> int;
+               end
+
+            structure Utimbuf =
+               struct
+                  val setActime =
+                     _import "Posix_FileSys_Utimbuf_setActime": time -> unit;
+                  val setModtime =
+                     _import "Posix_FileSys_Utimbuf_setModTime": time -> unit;
+                  val utime =
+                     _import "Posix_FileSys_Utimbuf_utime": NullString.t -> int;
+               end
+
+            val access =
+               _import "Posix_FileSys_access": NullString.t * word -> int;
+            val chdir = _import "Posix_FileSys_chdir": NullString.t -> int;
+            val chmod =
+               _import "Posix_FileSys_chmod": NullString.t * mode -> int;
+            val chown =
+               _import "Posix_FileSys_chown": NullString.t * uid * gid -> int;
+            val fchmod =
+               _import "Posix_FileSys_fchmod": fd * mode -> int;
+            val fchown =
+               _import "Posix_FileSys_fchown": fd * uid * gid -> int;
+            val fpathconf =
+               _import "Posix_FileSys_fpathconf": fd * int -> int;
+            val ftruncate =
+               _import "Posix_FileSys_ftruncate": fd * Position.int -> int;
+            val getcwd =
+               _import "Posix_FileSys_getcwd": char array * size -> cstring;
+            val link =
+               _import "Posix_FileSys_link": NullString.t * NullString.t -> int;
+            val mkdir =
+               _import "Posix_FileSys_mkdir": NullString.t * word -> int;
+            val mkfifo =
+               _import "Posix_FileSys_mkfifo": NullString.t * word -> int;
+            val openn =
+               _import "Posix_FileSys_open": NullString.t * word * mode -> int;
+            val pathconf =
+               _import "Posix_FileSys_pathconf": NullString.t * int -> int;
+            val readlink =
+               _import "Posix_FileSys_readlink"
+               : NullString.t * Word8.word array * int -> int;
+            val rename =
+               _import "Posix_FileSys_rename": NullString.t * NullString.t -> int;
+            val rmdir = _import "Posix_FileSys_rmdir": NullString.t -> int;
+            val symlink =
+               _import "Posix_FileSys_symlink"
+               : NullString.t * NullString.t -> int;
+            val umask = _import "Posix_FileSys_umask": word -> word;
+            val unlink = _import "Posix_FileSys_unlink": NullString.t -> int;
+
+            structure ST =
+               struct
+                  val isDir = _import "Posix_FileSys_ST_isDir": word -> bool;
+                  val isChr = _import "Posix_FileSys_ST_isChr": word -> bool;
+                  val isBlk = _import "Posix_FileSys_ST_isBlk": word -> bool;
+                  val isReg = _import "Posix_FileSys_ST_isReg": word -> bool;
+                  val isFIFO =
+                     _import "Posix_FileSys_ST_isFIFO": word -> bool;
+                  val isLink =
+                     _import "Posix_FileSys_ST_isLink": word -> bool;
+                  val isSock =
+                     _import "Posix_FileSys_ST_isSock": word -> bool;
+               end
+         end
+
+      structure IO =
+         struct
+            val F_DUPFD = _const "Posix_IO_F_DUPFD": int;
+            val F_GETFD = _const "Posix_IO_F_GETFD": int;
+            val F_SETFD = _const "Posix_IO_F_SETFD": int;
+            val F_GETFL = _const "Posix_IO_F_GETFL": int;
+            val F_SETFL = _const "Posix_IO_F_SETFL": int;
+            val F_GETLK = _const "Posix_IO_F_GETLK": int;
+            val F_SETLK = _const "Posix_IO_F_SETLK": int;
+            val F_RDLCK = _const "Posix_IO_F_RDLCK": int;
+            val F_WRLCK = _const "Posix_IO_F_WRLCK": int;
+            val F_UNLCK = _const "Posix_IO_F_UNLCK": int;
+            val F_SETLKW = _const "Posix_IO_F_SETLKW": int;
+(*          val F_GETOWN = _const "Posix_IO_F_GETOWN": int; *)
+(*          val F_SETOWN = _const "Posix_IO_F_SETOWN": int; *)
+            val O_ACCMODE = _const "Posix_IO_O_ACCMODE": word;
+            val SEEK_SET = _const "Posix_IO_SEEK_SET": int;
+            val SEEK_CUR = _const "Posix_IO_SEEK_CUR": int;
+            val SEEK_END = _const "Posix_IO_SEEK_END": int;
+
+            structure FD =
+               struct
+                  type flags = word
+                  val cloexec = _const "Posix_IO_FD_cloexec": flags;
+               end
+            
+            type file_desc = file_desc
+
+            structure FLock =
+               struct
+                  val fcntl = _import "Posix_IO_FLock_fcntl": fd * int -> int;
+                  val typ = _import "Posix_IO_FLock_type": unit -> int;
+                  val whence = _import "Posix_IO_FLock_whence": unit -> int;
+                  val start =
+                     _import "Posix_IO_FLock_start": unit -> Position.int;
+                  val len =
+                     _import "Posix_IO_FLock_len": unit -> Position.int;
+                  val pid = _import "Posix_IO_FLock_pid": unit -> Pid.t;
+                  val setType = _import "Posix_IO_FLock_setType": int -> unit;
+                  val setWhence =
+                     _import "Posix_IO_FLock_setWhence": int -> unit;
+                  val setStart =
+                     _import "Posix_IO_FLock_setStart": Position.int -> unit;
+                  val setLen =
+                     _import "Posix_IO_FLock_setLen": Position.int -> unit;
+(*                val setPid = _import "Posix_IO_FLock_setPid": Pid.t -> unit; *)
+               end
+            
+            val close = _import "Posix_IO_close": fd -> int;
+            val dup = _import "Posix_IO_dup": fd -> int;
+            val dup2 = _import "Posix_IO_dup2": fd * fd -> int;
+            val fcntl2 = _import "Posix_IO_fcntl2": fd * int -> int;
+            val fcntl3 = _import "Posix_IO_fcntl3": fd * int * int -> int;
+            val fsync = _import "Posix_IO_fsync": fd -> int;
+            val lseek =
+               _import "Posix_IO_lseek": fd * Position.int * int -> Position.int;
+            val pipe = _import "Posix_IO_pipe": fd array -> int;
+            val readChar =
+               _import "Posix_IO_read": fd * char array * int * size -> ssize;
+            val setbin = 
+               if let
+                     open Primitive.MLton.Platform.OS
+                  in
+                     case host of
+                        MinGW => true
+                      | _ => false
+                  end
+                  then _import "Posix_IO_setbin": fd -> unit;
+               else fn _ => raise Fail "setbin not defined"
+            val settext = 
+               if let
+                     open Primitive.MLton.Platform.OS
+                  in
+                     case host of
+                        MinGW => true
+                      | _ => false
+                  end
+                  then _import "Posix_IO_settext": fd -> unit;
+               else fn _ => raise Fail "settext not defined"
+            val writeChar =
+               _import "Posix_IO_write": fd * char array * int * size -> ssize;
+            val writeCharVec =
+               _import "Posix_IO_write": fd * char vector * int * size -> ssize;
+            val readWord8 =
+               _import "Posix_IO_read": fd * Word8.word array * int * size -> ssize;
+            val writeWord8 =
+               _import "Posix_IO_write": fd * Word8.word array * int * size -> ssize;
+            val writeWord8Vec =
+               _import "Posix_IO_write": fd * Word8.word vector * int * size -> ssize;
+         end           
+
+      structure SysDB =
+         struct
+            type gid = gid
+            type uid = uid
+
+            structure Passwd =
+               struct
+                  val name = _import "Posix_SysDB_Passwd_name": unit -> cstring;
+                  val uid = _import "Posix_SysDB_Passwd_uid": unit -> uid;
+                  val gid = _import "Posix_SysDB_Passwd_gid": unit -> gid;
+                  val dir = _import "Posix_SysDB_Passwd_dir": unit -> cstring;
+                  val shell =
+                     _import "Posix_SysDB_Passwd_shell": unit -> cstring;
+               end
+
+            val getpwnam = _import "Posix_SysDB_getpwnam": NullString.t -> bool;
+            val getpwuid = _import "Posix_SysDB_getpwuid": uid -> bool;
+
+            structure Group =
+               struct
+                  val name = _import "Posix_SysDB_Group_name": unit -> cstring;
+                  val gid = _import "Posix_SysDB_Group_gid": unit -> gid;
+                  val mem =
+                     _import "Posix_SysDB_Group_mem": unit -> cstringArray;
+               end
+
+            val getgrgid = _import "Posix_SysDB_getgrgid": gid -> bool;
+            val getgrnam = _import "Posix_SysDB_getgrnam": NullString.t -> bool;
+         end
+
+      structure TTY =
+         struct
+            type speed = word
+            val b0 = _const "Posix_TTY_b0": speed;
+            val b110 = _const "Posix_TTY_b110": speed;
+            val b1200 = _const "Posix_TTY_b1200": speed;
+            val b134 = _const "Posix_TTY_b134": speed;
+            val b150 = _const "Posix_TTY_b150": speed;
+            val b1800 = _const "Posix_TTY_b1800": speed;
+            val b19200 = _const "Posix_TTY_b19200": speed;
+            val b200 = _const "Posix_TTY_b200": speed;
+            val b2400 = _const "Posix_TTY_b2400": speed;
+            val b300 = _const "Posix_TTY_b300": speed;
+            val b38400 = _const "Posix_TTY_b38400": speed;
+            val b4800 = _const "Posix_TTY_b4800": speed;
+            val b50 = _const "Posix_TTY_b50": speed;
+            val b600 = _const "Posix_TTY_b600": speed;
+            val b75 = _const "Posix_TTY_b75": speed;
+            val b9600 = _const "Posix_TTY_b9600": speed;
+               
+            type file_desc = file_desc
+
+            structure V =
+               struct
+                  val eof = _const "Posix_TTY_V_eof": int;
+                  val eol = _const "Posix_TTY_V_eol": int;
+                  val erase = _const "Posix_TTY_V_erase": int;
+                  val intr = _const "Posix_TTY_V_intr": int;
+                  val kill = _const "Posix_TTY_V_kill": int;
+                  val min = _const "Posix_TTY_V_min": int;
+                  val nccs = _const "Posix_TTY_V_nccs": int;
+                  val quit = _const "Posix_TTY_V_quit": int;
+                  val start = _const "Posix_TTY_V_start": int;
+                  val stop = _const "Posix_TTY_V_stop": int;
+                  val susp = _const "Posix_TTY_V_susp": int;
+                  val time = _const "Posix_TTY_V_time": int;
+               end
+
+            structure I =
+               struct
+                  type flags = word
+                  val brkint = _const "Posix_TTY_I_brkint": flags;
+                  val icrnl = _const "Posix_TTY_I_icrnl": flags;
+                  val ignbrk = _const "Posix_TTY_I_ignbrk": flags;
+                  val igncr = _const "Posix_TTY_I_igncr": flags;
+                  val ignpar = _const "Posix_TTY_I_ignpar": flags;
+                  val inlcr = _const "Posix_TTY_I_inlcr": flags;
+                  val inpck = _const "Posix_TTY_I_inpck": flags;
+                  val istrip = _const "Posix_TTY_I_istrip": flags;
+                  val ixoff = _const "Posix_TTY_I_ixoff": flags;
+                  val ixon = _const "Posix_TTY_I_ixon": flags;
+                  val parmrk = _const "Posix_TTY_I_parmrk": flags;
+               end
+
+            structure O =
+               struct
+                  type flags = word
+                  val opost = _const "Posix_TTY_O_opost": flags;
+               end
+
+            structure C =
+               struct
+                  type flags = word
+                  val clocal = _const "Posix_TTY_C_clocal": flags;
+                  val cread = _const "Posix_TTY_C_cread": flags;
+                  val cs5 = _const "Posix_TTY_C_cs5": flags;
+                  val cs6 = _const "Posix_TTY_C_cs6": flags;
+                  val cs7 = _const "Posix_TTY_C_cs7": flags;
+                  val cs8 = _const "Posix_TTY_C_cs8": flags;
+                  val csize = _const "Posix_TTY_C_csize": flags;
+                  val cstopb = _const "Posix_TTY_C_cstopb": flags;
+                  val hupcl = _const "Posix_TTY_C_hupcl": flags;
+                  val parenb = _const "Posix_TTY_C_parenb": flags;
+                  val parodd = _const "Posix_TTY_C_parodd": flags;
+               end
+
+            structure L =
+               struct
+                  type flags = word
+                  val echo = _const "Posix_TTY_L_echo": flags;
+                  val echoe = _const "Posix_TTY_L_echoe": flags;
+                  val echok = _const "Posix_TTY_L_echok": flags;
+                  val echonl = _const "Posix_TTY_L_echonl": flags;
+                  val icanon = _const "Posix_TTY_L_icanon": flags;
+                  val iexten = _const "Posix_TTY_L_iexten": flags;
+                  val isig = _const "Posix_TTY_L_isig": flags;
+                  val noflsh = _const "Posix_TTY_L_noflsh": flags;
+                  val tostop = _const "Posix_TTY_L_tostop": flags;
+               end
+
+            structure TC =
+               struct
+                  type set_action = int
+
+                  val sadrain = _const "Posix_TTY_TC_sadrain": set_action;
+                  val saflush = _const "Posix_TTY_TC_saflush": set_action;
+                  val sanow = _const "Posix_TTY_TC_sanow": set_action;
+
+                  type flow_action = int
+
+                  val ion = _const "Posix_TTY_TC_ion": flow_action;
+                  val ioff = _const "Posix_TTY_TC_ioff": flow_action;
+                  val ooff = _const "Posix_TTY_TC_ooff": flow_action;
+                  val oon = _const "Posix_TTY_TC_oon": flow_action;
+
+                  type queue_sel = int
+
+                  val iflush = _const "Posix_TTY_TC_iflush": queue_sel;
+                  val ioflush = _const "Posix_TTY_TC_ioflush": queue_sel;
+                  val oflush = _const "Posix_TTY_TC_oflush": queue_sel;
+               end                
+
+            structure Termios =
+               struct
+                  type flag = word
+
+                  val iflag = _import "Posix_TTY_Termios_iflag": unit -> flag;
+                  val oflag = _import "Posix_TTY_Termios_oflag": unit -> flag;
+                  val cflag = _import "Posix_TTY_Termios_cflag": unit -> flag;
+                  val lflag = _import "Posix_TTY_Termios_lflag": unit -> flag;
+                  val cc = _import "Posix_TTY_Termios_cc": unit -> cstring;
+                  val ospeed =
+                     _import "Posix_TTY_Termios_cfgetospeed": unit -> speed;
+                  val ispeed =
+                     _import "Posix_TTY_Termios_cfgetispeed": unit -> speed;
+                  val setiflag =
+                     _import "Posix_TTY_Termios_setiflag": flag -> unit;
+                  val setoflag =
+                     _import "Posix_TTY_Termios_setoflag": flag -> unit;
+                  val setcflag =
+                     _import "Posix_TTY_Termios_setcflag": flag -> unit;
+                  val setlflag =
+                     _import "Posix_TTY_Termios_setlflag": flag -> unit;
+                  val setospeed =
+                     _import "Posix_TTY_Termios_setospeed": speed -> int;
+                  val setispeed =
+                     _import "Posix_TTY_Termios_setispeed": speed -> int;
+               end
+
+            val drain = _import "Posix_TTY_drain": fd -> int;
+            val flow = _import "Posix_TTY_flow": fd * TC.flow_action -> int;
+            val flush = _import "Posix_TTY_flush": fd * TC.queue_sel -> int;
+            val getattr = _import "Posix_TTY_getattr": fd -> int;
+            val getpgrp = _import "Posix_TTY_getpgrp": fd -> Pid.t;
+            val sendbreak = _import "Posix_TTY_sendbreak": fd * int -> int;
+            val setattr = _import "Posix_TTY_setattr": fd * TC.set_action -> int;
+            val setpgrp = _import "Posix_TTY_setpgrp": fd * Pid.t -> int;
+         end
+   end

Added: mlton/branches/on-20050822-x86_64-branch/basis-library/primitive/prim-basis.mlb
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library/primitive/prim-basis.mlb	2006-01-28 17:09:17 UTC (rev 4323)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/primitive/prim-basis.mlb	2006-01-28 17:54:57 UTC (rev 4324)
@@ -0,0 +1,21 @@
+(* 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.
+ *)
+
+ann 
+   "allowPrim true"
+   "deadCode true"
+   "nonexhaustiveMatch warn"
+   "redundantMatch warn"
+   "sequenceNonUnit warn"
+   "warnUnused true"
+in
+   local
+      _prim
+   in
+      prim-basis.sml
+   end
+end

Added: mlton/branches/on-20050822-x86_64-branch/basis-library/primitive/prim-basis.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library/primitive/prim-basis.sml	2006-01-28 17:09:17 UTC (rev 4323)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/primitive/prim-basis.sml	2006-01-28 17:54:57 UTC (rev 4324)
@@ -0,0 +1,454 @@
+(* Copyright (C) 1999-2006 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.
+ *)
+
+(* Primitive Basis (Definition) *)
+structure Bool =
+   struct
+      datatype t = datatype bool
+      datatype bool = datatype t
+   end
+structure Exn =
+   struct
+      type t = exn
+      type exn = t
+      exception Bind = Bind
+      exception Match = Match
+      exception PrimOverflow = Overflow
+   end
+structure List =
+   struct
+      datatype t = datatype list
+      datatype list = datatype t
+   end
+structure Ref =
+   struct
+      datatype t = datatype ref
+      datatype ref = datatype t
+   end
+structure Unit =
+   struct
+      type t = unit
+      type unit = t
+   end
+
+(* Primitive Basis (Basis Library) *)
+structure Array =
+   struct
+      type 'a t = 'a array
+      type 'a array = 'a t
+   end
+structure Vector =
+   struct
+      type 'a t = 'a vector
+      type 'a vector = 'a t
+   end
+
+(* Primitive Basis (Primitive Types) *)
+structure Char8 =
+   struct
+      type t = char8
+      type char = t
+   end
+structure Char16 =
+   struct
+      type t = char16
+      type char = t
+   end
+structure Char32 =
+   struct
+      type t = char32
+      type char = t
+   end
+
+structure Int1 =
+   struct
+      type t = int1
+      type int = t
+   end
+structure Int2 =
+   struct
+      type t = int2
+      type int = t
+   end
+structure Int3 =
+   struct
+      type t = int3
+      type int = t
+   end
+structure Int4 =
+   struct
+      type t = int4
+      type int = t
+   end
+structure Int5 =
+   struct
+      type t = int5
+      type int = t
+   end
+structure Int6 =
+   struct
+      type t = int6
+      type int = t
+   end
+structure Int7 =
+   struct
+      type t = int7
+      type int = t
+   end
+structure Int8 =
+   struct
+      type t = int8
+      type int = t
+   end
+structure Int9 =
+   struct
+      type t = int9
+      type int = t
+   end
+structure Int10 =
+   struct
+      type t = int10
+      type int = t
+   end
+structure Int11 =
+   struct
+      type t = int11
+      type int = t
+   end
+structure Int12 =
+   struct
+      type t = int12
+      type int = t
+   end
+structure Int13 =
+   struct
+      type t = int13
+      type int = t
+   end
+structure Int14 =
+   struct
+      type t = int14
+      type int = t
+   end
+structure Int15 =
+   struct
+      type t = int15
+      type int = t
+   end
+structure Int16 =
+   struct
+      type t = int16
+      type int = t
+   end
+structure Int17 =
+   struct
+      type t = int17
+      type int = t
+   end
+structure Int18 =
+   struct
+      type t = int18
+      type int = t
+   end
+structure Int19 =
+   struct
+      type t = int19
+      type int = t
+   end
+structure Int20 =
+   struct
+      type t = int20
+      type int = t
+   end
+structure Int21 =
+   struct
+      type t = int21
+      type int = t
+   end
+structure Int22 =
+   struct
+      type t = int22
+      type int = t
+   end
+structure Int23 =
+   struct
+      type t = int23
+      type int = t
+   end
+structure Int24 =
+   struct
+      type t = int24
+      type int = t
+   end
+structure Int25 =
+   struct
+      type t = int25
+      type int = t
+   end
+structure Int26 =
+   struct
+      type t = int26
+      type int = t
+   end
+structure Int27 =
+   struct
+      type t = int27
+      type int = t
+   end
+structure Int28 =
+   struct
+      type t = int28
+      type int = t
+   end
+structure Int29 =
+   struct
+      type t = int29
+      type int = t
+   end
+structure Int30 =
+   struct
+      type t = int30
+      type int = t
+   end
+structure Int31 =
+   struct
+      type t = int31
+      type int = t
+   end
+structure Int32 =
+   struct
+      type t = int32
+      type int = t
+   end
+structure Int64 =
+   struct
+      type t = int64
+      type int = t
+   end
+structure IntInf =
+   struct
+      type t = intInf
+      type int = t
+   end
+
+structure Real32 =
+   struct
+      type t = real32
+      type real = t
+   end
+structure Real64 =
+   struct
+      type t = real64
+      type real = t
+   end
+
+structure String8 =
+   struct
+      type t = Char8.t vector
+      type string = t
+   end
+structure String16 =
+   struct
+      type t = Char16.t vector
+      type string = t
+   end
+structure String32 =
+   struct
+      type t = Char32.t vector
+      type string = t
+   end
+
+structure Word1 =
+   struct
+      type t = word1
+      type word = t
+   end
+structure Word2 =
+   struct
+      type t = word2
+      type word = t
+   end
+structure Word3 =
+   struct
+      type t = word3
+      type word = t
+   end
+structure Word4 =
+   struct
+      type t = word4
+      type word = t
+   end
+structure Word5 =
+   struct
+      type t = word5
+      type word = t
+   end
+structure Word6 =
+   struct
+      type t = word6
+      type word = t
+   end
+structure Word7 =
+   struct
+      type t = word7
+      type word = t
+   end
+structure Word8 =
+   struct
+      type t = word8
+      type word = t
+   end
+structure Word9 =
+   struct
+      type t = word9
+      type word = t
+   end
+structure Word10 =
+   struct
+      type t = word10
+      type word = t
+   end
+structure Word11 =
+   struct
+      type t = word11
+      type word = t
+   end
+structure Word12 =
+   struct
+      type t = word12
+      type word = t
+   end
+structure Word13 =
+   struct
+      type t = word13
+      type word = t
+   end
+structure Word14 =
+   struct
+      type t = word14
+      type word = t
+   end
+structure Word15 =
+   struct
+      type t = word15
+      type word = t
+   end
+structure Word16 =
+   struct
+      type t = word16
+      type word = t
+   end
+structure Word17 =
+   struct
+      type t = word17
+      type word = t
+   end
+structure Word18 =
+   struct
+      type t = word18
+      type word = t
+   end
+structure Word19 =
+   struct
+      type t = word19
+      type word = t
+   end
+structure Word20 =
+   struct
+      type t = word20
+      type word = t
+   end
+structure Word21 =
+   struct
+      type t = word21
+      type word = t
+   end
+structure Word22 =
+   struct
+      type t = word22
+      type word = t
+   end
+structure Word23 =
+   struct
+      type t = word23
+      type word = t
+   end
+structure Word24 =
+   struct
+      type t = word24
+      type word = t
+   end
+structure Word25 =
+   struct
+      type t = word25
+      type word = t
+   end
+structure Word26 =
+   struct
+      type t = word26
+      type word = t
+   end
+structure Word27 =
+   struct
+      type t = word27
+      type word = t
+   end
+structure Word28 =
+   struct
+      type t = word28
+      type word = t
+   end
+structure Word29 =
+   struct
+      type t = word29
+      type word = t
+   end
+structure Word30 =
+   struct
+      type t = word30
+      type word = t
+   end
+structure Word31 =
+   struct
+      type t = word31
+      type word = t
+   end
+structure Word32 =
+   struct
+      type t = word32
+      type word = t
+   end
+structure Word64 =
+   struct
+      type t = word64
+      type word = t
+   end
+
+(* Primitive Basis (MLton Extensions) *)
+structure Pointer =
+   struct
+      type t = pointer
+   end
+structure Thread =
+   struct
+      type t = thread
+   end
+structure Weak =
+   struct
+      type 'a t = 'a weak
+   end
+
+
+(* Top-level bindings *)
+datatype bool = datatype Bool.bool
+type exn = Exn.exn
+datatype list = datatype List.list
+datatype ref = datatype Ref.ref
+type unit = Unit.unit
+type 'a array = 'a Array.array
+type 'a vector = 'a Vector.vector

Copied: mlton/branches/on-20050822-x86_64-branch/basis-library/primitive/primitive.mlb (from rev 4323, mlton/branches/on-20050822-x86_64-branch/basis-library/libs/primitive.mlb)
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library/libs/primitive.mlb	2006-01-28 17:09:17 UTC (rev 4323)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/primitive/primitive.mlb	2006-01-28 17:54:57 UTC (rev 4324)
@@ -0,0 +1,28 @@
+(* 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.
+ *)
+
+ann 
+   "allowConstant true"
+   "allowFFI true"
+   "allowPrim true"
+   "allowRebindEquals true"
+   "deadCode true"
+   "nonexhaustiveMatch warn"
+   "redundantMatch warn"
+   "sequenceNonUnit warn"
+   "warnUnused true"
+in
+   prim-basis.mlb
+   ann "forceUsed" in
+      ../config/c/$(TARGET_ARCH)-$(TARGET_OS)/c-types.sml
+   end
+   primitive.sml
+   posix-primitive.sml
+   ann "forceUsed" in
+      basis-ffi.sml
+   end
+end

Copied: mlton/branches/on-20050822-x86_64-branch/basis-library/primitive/primitive.sml (from rev 4323, mlton/branches/on-20050822-x86_64-branch/basis-library/misc/primitive.sml)
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library/misc/primitive.sml	2006-01-28 17:09:17 UTC (rev 4323)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/primitive/primitive.sml	2006-01-28 17:54:57 UTC (rev 4324)
@@ -0,0 +1,2129 @@
+(* 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.
+ *)
+
+(* Primitive names are special -- see atoms/prim.fun. *)
+
+infix 4 = (* <> > >= < <= *)
+
+val op = = fn z => _prim "MLton_equal": ''a * ''a -> bool; z
+
+structure Char = Char8
+type char = Char.char
+structure Int = Int32
+type int = Int.int
+structure Position = Int64
+structure Real = Real64
+type real = Real.real
+
+structure String = String8
+type string = String.string
+
+structure PreThread :> sig type t end = struct type t = Thread.t end
+structure Thread :> sig type t end = struct type t = Thread.t end
+
+structure Word = Word32
+type word = Word.word
+structure LargeWord = Word64
+
+(* NullString is used for strings that must be passed to C and hence must be
+ * null terminated.  After the Primitive structure is defined,
+ * NullString.fromString is replaced by a version that checks that the string
+ * is indeed null terminated.  See the bottom of this file.
+ *)
+structure NullString :>
+   sig
+      type t
+
+      val fromString: string -> t
+   end =
+   struct
+      type t = string
+
+      val fromString = fn s => s
+   end
+
+structure GetSet =
+   struct
+      type 'a t = (unit -> 'a) * ('a -> unit)
+   end
+
+structure Pid :> sig
+                    eqtype t
+
+                    val fromInt: int -> t
+                    val toInt: t -> int
+                 end =
+   struct
+      type t = int
+
+      val fromInt = fn i => i
+      val toInt = fn i => i
+      val _ = fromInt
+   end
+
+exception Bind = Exn.Bind   
+exception Fail of string
+exception Match = Exn.Match
+exception PrimOverflow = Exn.PrimOverflow
+exception Overflow
+exception Size
+
+val wrapOverflow: ('a -> 'b) -> ('a -> 'b) =
+   fn f => fn a => f a handle PrimOverflow => raise Overflow
+
+datatype 'a option = NONE | SOME of 'a
+
+fun not b = if b then false else true
+   
+functor Comparisons (type t
+                     val < : t * t -> bool) =
+   struct
+      fun <= (a, b) = not (< (b, a))
+      fun > (a, b) = < (b, a)
+      fun >= (a, b) = <= (b, a)
+   end
+
+functor RealComparisons (type t
+                         val < : t * t -> bool
+                         val <= : t * t -> bool) =
+   struct
+      fun > (a, b) = < (b, a)
+      fun >= (a, b) = <= (b, a)
+   end
+
+structure Primitive =
+   struct
+      val bug = _import "MLton_bug": NullString.t -> unit;
+      val debug = _command_line_const "MLton.debug": bool = false;
+      val detectOverflow =
+         _command_line_const "MLton.detectOverflow": bool = true;
+      val eq = _prim "MLton_eq": 'a * 'a -> bool;
+      val installSignalHandler =
+         _prim "MLton_installSignalHandler": unit -> unit;
+      val safe = _command_line_const "MLton.safe": bool = true;
+      val touch = _prim "MLton_touch": 'a -> unit;
+      val usesCallcc: bool ref = ref false;
+
+      structure Stdio =
+         struct
+            val print = _import "Stdio_print": string -> unit;
+         end
+
+      structure Array =
+         struct
+            val array0Const = _prim "Array_array0Const": unit -> 'a array;
+            val length = _prim "Array_length": 'a array -> int;
+            (* There is no maximum length on arrays, so maxLen = maxInt. *)
+            val maxLen: int = 0x7FFFFFFF
+            val sub = _prim "Array_sub": 'a array * int -> 'a;
+            val update = _prim "Array_update": 'a array * int * 'a -> unit;
+         end
+
+      structure CString =
+         struct
+            type t = Pointer.t
+         end
+      structure CStringArray =
+         struct
+            type t = Pointer.t
+         end
+
+      structure GCState =
+         struct
+            type t = Pointer.t
+
+            val gcState = #1 _symbol "gcStateAddress": t GetSet.t; ()
+         end
+      
+      structure CallStack =
+         struct
+            (* The most recent caller is at index 0 in the array. *)
+            datatype t = T of int array
+
+            val callStack =
+               _import "GC_callStack": GCState.t * int array -> unit;
+            val frameIndexSourceSeq =
+               _import "GC_frameIndexSourceSeq": GCState.t * int -> Pointer.t;
+            val keep = _command_line_const "CallStack.keep": bool = false;
+            val numStackFrames =
+               _import "GC_numStackFrames": GCState.t -> int;
+            val sourceName = _import "GC_sourceName": GCState.t * int -> CString.t;
+         end
+
+      structure Char =
+         struct
+            open Char
+               
+            val op < = _prim "WordU8_lt": char * char -> bool;
+            val chr = _prim "WordS32_toWord8": int -> char;
+            val ord = _prim "WordU8_toWord32": char -> int;
+            val toInt8 = _prim "WordS8_toWord8": char -> Int8.int;
+            val fromInt8 = _prim "WordS8_toWord8": Int8.int -> char;
+            val toWord8 = _prim "WordU8_toWord8": char -> Word8.word;
+            val fromWord8 = _prim "WordU8_toWord8": Word8.word -> char;
+         end
+
+      structure Char =
+         struct
+            open Char
+            local
+               structure S = Comparisons (Char)
+            in
+               open S
+            end
+         end
+
+      structure Char2 =
+         struct
+            open Char16
+
+            val op < = _prim "WordU16_lt": char * char -> bool;
+            val chr = _prim "WordS32_toWord16": int -> char;
+            val ord = _prim "WordU16_toWord32": char -> int;
+            val toInt16 = _prim "WordS16_toWord16": char -> Int16.int;
+            val fromInt16 = _prim "WordS16_toWord16": Int16.int -> char;
+            (* val toWord16 = _prim "WordU16_toWord16": char -> Word16.word; *)
+            (* val fromWord16 = _prim "WordU16_toWord16": Word16.word -> char; *)
+         end
+      
+      structure Char4 =
+         struct
+            open Char32
+
+            val op < = _prim "WordU32_lt": char * char -> bool;
+            val chr = _prim "WordS32_toWord32": int -> char;
+            val ord = _prim "WordU32_toWord32": char -> int;
+            val toInt32 = _prim "WordS32_toWord32": char -> Int32.int;
+            val fromInt32 = _prim "WordS32_toWord32": Int32.int -> char;
+            (* val toWord32 = _prim "WordU32_toWord32": char -> Word32.word; *)
+            (* val fromWord32 = _prim "WordU32_toWord32": Word32.word -> char; *)
+         end
+
+      structure CommandLine =
+         struct
+            val argc = #1 _symbol "CommandLine_argc": int GetSet.t;
+            val argv = #1 _symbol "CommandLine_argv": CStringArray.t GetSet.t;
+            val commandName = #1 _symbol "CommandLine_commandName": CString.t GetSet.t;
+         end
+
+      structure Exn =
+         struct
+            (* The polymorphism with extra and setInitExtra is because primitives
+             * are only supposed to deal with basic types.  The polymorphism
+             * allows the various passes like monomorphisation to translate
+             * the types appropriately.
+             *)
+            type extra = CallStack.t option
+
+            val extra = _prim "Exn_extra": exn -> 'a;
+            val extra: exn -> extra = extra
+            val name = _prim "Exn_name": exn -> string;
+            val keepHistory =
+               _command_line_const "Exn.keepHistory": bool = false;
+            val setExtendExtra = _prim "Exn_setExtendExtra": ('a -> 'a) -> unit;
+            val setExtendExtra: (extra -> extra) -> unit = setExtendExtra
+            val setInitExtra = _prim "Exn_setInitExtra": 'a -> unit;
+            val setInitExtra: extra -> unit = setInitExtra
+         end
+
+      structure FFI =
+         struct
+            val getOp = #1 _symbol "MLton_FFI_op": int GetSet.t;
+            val int8Array = #1 _symbol "MLton_FFI_Int8": Pointer.t GetSet.t; ()
+            val int16Array = #1 _symbol "MLton_FFI_Int16": Pointer.t GetSet.t; ()
+            val int32Array = #1 _symbol "MLton_FFI_Int32": Pointer.t GetSet.t; ()
+            val int64Array = #1 _symbol "MLton_FFI_Int64": Pointer.t GetSet.t; ()
+            val numExports = _build_const "MLton_FFI_numExports": int;
+            val pointerArray = #1 _symbol "MLton_FFI_Pointer": Pointer.t GetSet.t; ()
+            val real32Array = #1 _symbol "MLton_FFI_Real32": Pointer.t GetSet.t; ()
+            val real64Array = #1 _symbol "MLton_FFI_Real64": Pointer.t GetSet.t; ()
+            val word8Array = #1 _symbol "MLton_FFI_Word8": Pointer.t GetSet.t; ()
+            val word16Array = #1 _symbol "MLton_FFI_Word16": Pointer.t GetSet.t; ()
+            val word32Array = #1 _symbol "MLton_FFI_Word32": Pointer.t GetSet.t; ()
+            val word64Array = #1 _symbol "MLton_FFI_Word64": Pointer.t GetSet.t; ()
+         end
+
+      structure GC =
+         struct
+            val collect = _prim "GC_collect": unit -> unit;
+            val pack = _import "GC_pack": GCState.t -> unit;
+            val setHashConsDuringGC =
+               _import "GC_setHashConsDuringGC": GCState.t * bool -> unit;
+            val setMessages = 
+               _import "GC_setMessages": GCState.t * bool -> unit;
+            val setRusageMeasureGC = 
+               _import "GC_setRusageMeasureGC": GCState.t * bool -> unit;
+            val setSummary = 
+               _import "GC_setSummary": GCState.t * bool -> unit;
+            val unpack = 
+               _import "GC_unpack": GCState.t -> unit;
+         end
+      
+      structure IEEEReal =
+         struct
+            structure RoundingMode =
+               struct
+                  type t = int
+                     
+                  val toNearest = _const "FE_TONEAREST": t;
+                  val downward = _const "FE_DOWNWARD": t;
+                  val noSupport = _const "FE_NOSUPPORT": t;
+                  val upward = _const "FE_UPWARD": t;
+                  val towardZero = _const "FE_TOWARDZERO": t;
+               end
+            
+            val getRoundingMode =
+               _import "IEEEReal_getRoundingMode": unit -> int;
+            val setRoundingMode =
+               _import "IEEEReal_setRoundingMode": int -> unit;
+         end
+
+      structure Int1 =
+         struct
+            open Int1
+            type big = Int8.int
+            val fromBigUnsafe = _prim "WordU8_toWord1": big -> int;
+            val precision' = 1
+            val toBig = _prim "WordU1_toWord8": int -> big;
+         end
+      structure Int2 =
+         struct
+            open Int2
+            type big = Int8.int
+            val fromBigUnsafe = _prim "WordU8_toWord2": big -> int;
+            val precision' = 2
+            val toBig = _prim "WordU2_toWord8": int -> big;
+         end
+      structure Int3 =
+         struct
+            open Int3
+            type big = Int8.int
+            val fromBigUnsafe = _prim "WordU8_toWord3": big -> int;
+            val precision' = 3
+            val toBig = _prim "WordU3_toWord8": int -> big;
+         end
+      structure Int4 =
+         struct
+            open Int4
+            type big = Int8.int
+            val fromBigUnsafe = _prim "WordU8_toWord4": big -> int;
+            val precision' = 4
+            val toBig = _prim "WordU4_toWord8": int -> big;
+         end
+      structure Int5 =
+         struct
+            open Int5
+            type big = Int8.int
+            val fromBigUnsafe = _prim "WordU8_toWord5": big -> int;
+            val precision' = 5
+            val toBig = _prim "WordU5_toWord8": int -> big;
+         end
+      structure Int6 =
+         struct
+            open Int6
+            type big = Int8.int
+            val fromBigUnsafe = _prim "WordU8_toWord6": big -> int;
+            val precision' = 6
+            val toBig = _prim "WordU6_toWord8": int -> big;
+         end
+      structure Int7 =
+         struct
+            open Int7
+            type big = Int8.int
+            val fromBigUnsafe = _prim "WordU8_toWord7": big -> int;
+            val precision' = 7
+            val toBig = _prim "WordU7_toWord8": int -> big;
+         end
+      structure Int8 =
+         struct
+            type t = Int8.int
+            type int = t
+               
+            val precision' : Int.int = 8
+            val maxInt' : int = 0x7f
+            val minInt' : int = ~0x80
+
+            val *? = _prim "WordS8_mul": int * int -> int;
+            val * =
+               if detectOverflow
+                  then wrapOverflow (_prim "WordS8_mulCheck": int * int -> int;)
+               else *?
+            val +? = _prim "Word8_add": int * int -> int;
+            val + =
+               if detectOverflow
+                  then wrapOverflow (_prim "WordS8_addCheck": int * int -> int;)
+               else +?
+            val -? = _prim "Word8_sub": int * int -> int;
+            val - =
+               if detectOverflow
+                  then wrapOverflow (_prim "WordS8_subCheck": int * int -> int;)
+               else -?
+            val op < = _prim "WordS8_lt": int * int -> bool;
+            val quot = _prim "WordS8_quot": int * int -> int;
+            val rem = _prim "WordS8_rem": int * int -> int;
+            val << = _prim "Word8_lshift": int * Word.word -> int;
+            val >> = _prim "WordU8_rshift": int * Word.word -> int;
+            val ~>> = _prim "WordS8_rshift": int * Word.word -> int;
+            val ~? = _prim "Word8_neg": int -> int; 
+            val ~ =
+               if detectOverflow
+                  then wrapOverflow (_prim "Word8_negCheck": int -> int;)
+               else ~?
+            val andb = _prim "Word8_andb": int * int -> int;
+            val fromInt = _prim "WordS32_toWord8": Int.int -> int;
+            val toInt = _prim "WordS8_toWord32": int -> Int.int;
+         end
+      structure Int8 =
+         struct
+            open Int8
+            local
+               structure S = Comparisons (Int8)
+            in
+               open S
+            end
+         end
+      structure Int9 =
+         struct
+            open Int9
+            type big = Int16.int
+            val fromBigUnsafe = _prim "WordU16_toWord9": big -> int;
+            val precision' = 9
+            val toBig = _prim "WordU9_toWord16": int -> big;
+         end
+      structure Int10 =
+         struct
+            open Int10
+            type big = Int16.int
+            val fromBigUnsafe = _prim "WordU16_toWord10": big -> int;
+            val precision' = 10
+            val toBig = _prim "WordU10_toWord16": int -> big;
+         end
+      structure Int11 =
+         struct
+            open Int11
+            type big = Int16.int
+            val fromBigUnsafe = _prim "WordU16_toWord11": big -> int;
+            val precision' = 11
+            val toBig = _prim "WordU11_toWord16": int -> big;
+         end
+      structure Int12 =
+         struct
+            open Int12
+            type big = Int16.int
+            val fromBigUnsafe = _prim "WordU16_toWord12": big -> int;
+            val precision' = 12
+            val toBig = _prim "WordU12_toWord16": int -> big;
+         end
+      structure Int13 =
+         struct
+            open Int13
+            type big = Int16.int
+            val fromBigUnsafe = _prim "WordU16_toWord13": big -> int;
+            val precision' = 13
+            val toBig = _prim "WordU13_toWord16": int -> big;
+         end
+      structure Int14 =
+         struct
+            open Int14
+            type big = Int16.int
+            val fromBigUnsafe = _prim "WordU16_toWord14": big -> int;
+            val precision' = 14
+            val toBig = _prim "WordU14_toWord16": int -> big;
+         end
+      structure Int15 =
+         struct
+            open Int15
+            type big = Int16.int
+            val fromBigUnsafe = _prim "WordU16_toWord15": big -> int;
+            val precision' = 15
+            val toBig = _prim "WordU15_toWord16": int -> big;
+         end    
+      structure Int16 =
+         struct
+            type t = Int16.int
+            type int = t
+               
+            val precision' : Int.int = 16
+            val maxInt' : int = 0x7fff
+            val minInt' : int = ~0x8000
+
+            val *? = _prim "WordS16_mul": int * int -> int;
+            val * =
+               if detectOverflow
+                  then (wrapOverflow
+                        (_prim "WordS16_mulCheck": int * int -> int;))
+               else *?
+            val +? = _prim "Word16_add": int * int -> int;
+            val + =
+               if detectOverflow
+                  then (wrapOverflow
+                        (_prim "WordS16_addCheck": int * int -> int;))
+               else +?
+            val -? = _prim "Word16_sub": int * int -> int;
+            val - =
+               if detectOverflow
+                  then (wrapOverflow
+                        (_prim "WordS16_subCheck": int * int -> int;))
+               else -?
+            val op < = _prim "WordS16_lt": int * int -> bool;
+            val quot = _prim "WordS16_quot": int * int -> int;
+            val rem = _prim "WordS16_rem": int * int -> int;
+            val << = _prim "Word16_lshift": int * Word.word -> int;
+            val >> = _prim "WordU16_rshift": int * Word.word -> int;
+            val ~>> = _prim "WordS16_rshift": int * Word.word -> int;
+            val ~? = _prim "Word16_neg": int -> int; 
+            val ~ =
+               if detectOverflow
+                  then wrapOverflow (_prim "Word16_negCheck": int -> int;)
+               else ~?
+            val andb = _prim "Word16_andb": int * int -> int;
+            val fromInt = _prim "WordS32_toWord16": Int.int -> int;
+            val toInt = _prim "WordS16_toWord32": int -> Int.int;
+         end
+      structure Int16 =
+         struct
+            open Int16
+            local
+               structure S = Comparisons (Int16)
+            in
+               open S
+            end
+         end
+      structure Int17 =
+         struct
+            open Int17
+            type big = Int32.int
+            val fromBigUnsafe = _prim "WordU32_toWord17": big -> int;
+            val precision' = 17
+            val toBig = _prim "WordU17_toWord32": int -> big;
+         end
+      structure Int18 =
+         struct
+            open Int18
+            type big = Int32.int
+            val fromBigUnsafe = _prim "WordU32_toWord18": big -> int;
+            val precision' = 18
+            val toBig = _prim "WordU18_toWord32": int -> big;
+         end
+      structure Int19 =
+         struct
+            open Int19
+            type big = Int32.int
+            val fromBigUnsafe = _prim "WordU32_toWord19": big -> int;
+            val precision' = 19
+            val toBig = _prim "WordU19_toWord32": int -> big;
+         end
+      structure Int20 =
+         struct
+            open Int20
+            type big = Int32.int
+            val fromBigUnsafe = _prim "WordU32_toWord20": big -> int;
+            val precision' = 20
+            val toBig = _prim "WordU20_toWord32": int -> big;
+         end
+      structure Int21 =
+         struct
+            open Int21
+            type big = Int32.int
+            val fromBigUnsafe = _prim "WordU32_toWord21": big -> int;
+            val precision' = 21
+            val toBig = _prim "WordU21_toWord32": int -> big;
+         end
+      structure Int22 =
+         struct
+            open Int22
+            type big = Int32.int
+            val fromBigUnsafe = _prim "WordU32_toWord22": big -> int;
+            val precision' = 22
+            val toBig = _prim "WordU22_toWord32": int -> big;
+         end
+      structure Int23 =
+         struct
+            open Int23
+            type big = Int32.int
+            val fromBigUnsafe = _prim "WordU32_toWord23": big -> int;
+            val precision' = 23
+            val toBig = _prim "WordU23_toWord32": int -> big;
+         end
+      structure Int24 =
+         struct
+            open Int24
+            type big = Int32.int
+            val fromBigUnsafe = _prim "WordU32_toWord24": big -> int;
+            val precision' = 24
+            val toBig = _prim "WordU24_toWord32": int -> big;
+         end
+      structure Int25 =
+         struct
+            open Int25
+            type big = Int32.int
+            val fromBigUnsafe = _prim "WordU32_toWord25": big -> int;
+            val precision' = 25
+            val toBig = _prim "WordU25_toWord32": int -> big;
+         end
+      structure Int26 =
+         struct
+            open Int26
+            type big = Int32.int
+            val fromBigUnsafe = _prim "WordU32_toWord26": big -> int;
+            val precision' = 26
+            val toBig = _prim "WordU26_toWord32": int -> big;
+         end
+      structure Int27 =
+         struct
+            open Int27
+            type big = Int32.int
+            val fromBigUnsafe = _prim "WordU32_toWord27": big -> int;
+            val precision' = 27
+            val toBig = _prim "WordU27_toWord32": int -> big;
+         end
+      structure Int28 =
+         struct
+            open Int28
+            type big = Int32.int
+            val fromBigUnsafe = _prim "WordU32_toWord28": big -> int;
+            val precision' = 28
+            val toBig = _prim "WordU28_toWord32": int -> big;
+         end
+      structure Int29 =
+         struct
+            open Int29
+            type big = Int32.int
+            val fromBigUnsafe = _prim "WordU32_toWord29": big -> int;
+            val precision' = 29
+            val toBig = _prim "WordU29_toWord32": int -> big;
+         end
+      structure Int30 =
+         struct
+            open Int30
+            type big = Int32.int
+            val fromBigUnsafe = _prim "WordU32_toWord30": big -> int;
+            val precision' = 30
+            val toBig = _prim "WordU30_toWord32": int -> big;
+         end
+      structure Int31 =
+         struct
+            open Int31
+            type big = Int32.int
+            val fromBigUnsafe = _prim "WordU32_toWord31": big -> int;
+            val precision' = 31
+            val toBig = _prim "WordU31_toWord32": int -> big;
+         end
+      structure Int32 =
+         struct
+            type t = Int32.int
+            type int = t
+
+            val precision' : Int.int = 32
+            val maxInt' : int = 0x7fffffff
+            val minInt' : int = ~0x80000000
+
+            val *? = _prim "WordS32_mul": int * int -> int;
+            val * =
+               if detectOverflow
+                  then (wrapOverflow
+                        (_prim "WordS32_mulCheck": int * int -> int;))
+               else *?
+            val +? = _prim "Word32_add": int * int -> int;
+            val + =
+               if detectOverflow
+                  then (wrapOverflow
+                        (_prim "WordS32_addCheck": int * int -> int;))
+               else +?
+            val -? = _prim "Word32_sub": int * int -> int;
+            val - =
+               if detectOverflow
+                  then (wrapOverflow
+                        (_prim "WordS32_subCheck": int * int -> int;))
+               else -?
+            val op < = _prim "WordS32_lt": int * int -> bool;
+            val quot = _prim "WordS32_quot": int * int -> int;
+            val rem = _prim "WordS32_rem": int * int -> int;
+            val << = _prim "Word32_lshift": int * Word.word -> int;
+            val >> = _prim "WordU32_rshift": int * Word.word -> int;
+            val ~>> = _prim "WordS32_rshift": int * Word.word -> int;
+            val ~? = _prim "Word32_neg": int -> int; 
+            val ~ =
+               if detectOverflow
+                  then wrapOverflow (_prim "Word32_negCheck": int -> int;)
+               else ~?
+            val andb = _prim "Word32_andb": int * int -> int;
+            val fromInt : int -> int = fn x => x
+            val toInt : int -> int = fn x => x
+         end
+      structure Int32 =
+         struct
+            open Int32
+            local
+               structure S = Comparisons (Int32)
+            in
+               open S
+            end
+         end
+      structure Int = Int32
+      structure Int64 =
+         struct
+            type t = Int64.int
+            type int = t
+
+            val precision' : Int.int = 64
+            val maxInt' : int = 0x7FFFFFFFFFFFFFFF
+            val minInt' : int = ~0x8000000000000000
+
+            val *? = _prim "WordS64_mul": int * int -> int;
+            val * = fn _ => raise Fail "Int64.* unimplemented"
+(*
+            val * =
+               if detectOverflow
+                  then _prim "WordS64_mulCheck": int * int -> int;
+               else *?
+*)
+            val +? = _prim "Word64_add": int * int -> int;
+            val + =
+               if detectOverflow
+                  then (wrapOverflow
+                        (_prim "WordS64_addCheck": int * int -> int;))
+               else +?
+            val -? = _prim "Word64_sub": int * int -> int;
+            val - =
+               if detectOverflow
+                  then (wrapOverflow
+                        (_prim "WordS64_subCheck": int * int -> int;))
+               else -?
+            val op < = _prim "WordS64_lt": int * int -> bool;
+            val << = _prim "Word64_lshift": int * Word.word -> int;
+            val >> = _prim "WordU64_rshift": int * Word.word -> int;
+            val ~>> = _prim "WordS64_rshift": int * Word.word -> int;
+            val quot = _prim "WordS64_quot": int * int -> int;
+            val rem = _prim "WordS64_rem": int * int -> int;
+            val ~? = _prim "Word64_neg": int -> int; 
+            val ~ =
+               if detectOverflow
+                  then wrapOverflow (_prim "Word64_negCheck": int -> int;)
+               else ~?
+            val andb = _prim "Word64_andb": int * int -> int;
+            val fromInt = _prim "WordS32_toWord64": Int.int -> int;
+            val fromWord = _prim "WordU32_toWord64": word -> int;
+            val toInt = _prim "WordU64_toWord32": int -> Int.int;
+            val toWord = _prim "WordU64_toWord32": int -> word;
+         end
+      structure Int64 =
+         struct
+            open Int64
+            local
+               structure S = Comparisons (Int64)
+            in
+               open S
+            end
+         end
+
+      structure Array =
+         struct
+            open Array
+
+            val array = _prim "Array_array": int -> 'a array;
+            val array =
+               fn n => if safe andalso Int.< (n, 0)
+                          then raise Size
+                       else array n
+         end
+
+      structure IntInf =
+         struct
+            open IntInf
+
+            val + = _prim "IntInf_add": int * int * word -> int;
+            val andb = _prim "IntInf_andb": int * int * word -> int;
+            val ~>> = _prim "IntInf_arshift": int * word * word -> int;
+            val compare = _prim "IntInf_compare": int * int -> Int.int;
+            val fromVector = _prim "WordVector_toIntInf": word vector -> int;
+            val fromWord = _prim "Word_toIntInf": word -> int;
+            val gcd = _prim "IntInf_gcd": int * int * word -> int;
+            val << = _prim "IntInf_lshift": int * word * word -> int;
+            val * = _prim "IntInf_mul": int * int * word -> int;
+            val ~ = _prim "IntInf_neg": int * word -> int;
+            val notb = _prim "IntInf_notb": int * word -> int;
+            val orb = _prim "IntInf_orb": int * int * word -> int;
+            val quot = _prim "IntInf_quot": int * int * word -> int;
+            val rem = _prim "IntInf_rem": int * int * word -> int;
+            val smallMul =
+               _import "IntInf_smallMul": word * word * word ref -> word;
+            val - = _prim "IntInf_sub": int * int * word -> int; 
+            val toString
+               = _prim "IntInf_toString": int * Int.int * word -> string;
+            val toVector = _prim "IntInf_toVector": int -> word vector;
+            val toWord = _prim "IntInf_toWord": int -> word;
+            val xorb = _prim "IntInf_xorb": int * int * word -> int;
+         end
+
+      structure Itimer =
+         struct
+            type which = int
+               
+            val prof = _const "Itimer_prof": which;
+            val real = _const "Itimer_real": which;
+            val set =
+               _import "Itimer_set": which * int * int * int * int -> unit;
+            val virtual = _const "Itimer_virtual": which;
+         end
+
+      structure MLton =
+         struct
+            structure Codegen =
+               struct
+                  datatype t = Bytecode | C | Native
+
+                  val codegen =
+                     case _build_const "MLton_Codegen_codegen": int; of
+                        0 => Bytecode
+                      | 1 => C
+                      | 2 => Native
+                      | _ => raise Fail "MLton_Codegen_codegen"
+
+                  val isBytecode = codegen = Bytecode
+                  (* val isC = codegen = C *)
+                  val isNative = codegen = Native
+               end
+            
+            (* val deserialize = _prim "MLton_deserialize": Word8Vector.vector -> 'a ref; *)
+            (* val serialize = _prim "MLton_serialize": 'a ref -> Word8Vector.vector; *)
+            val share = _prim "MLton_share": 'a -> unit;
+            val size = _prim "MLton_size": 'a ref -> int;
+
+            structure Platform =
+               struct
+                  structure Arch =
+                     struct
+                        datatype t = Alpha | AMD64 | ARM | HPPA | IA64 | m68k |
+                                     MIPS | PowerPC | S390 | Sparc | X86
+                        
+                        val host: t =
+                           case _const "MLton_Platform_Arch_host": string; of
+                              "alpha" => Alpha
+                            | "amd64" => AMD64
+                            | "arm" => ARM
+                            | "hppa" => HPPA
+                            | "ia64" => IA64
+                            | "m68k" => m68k
+                            | "mips" => MIPS
+                            | "powerpc" => PowerPC
+                            | "s390" => S390
+                            | "sparc" => Sparc
+                            | "x86" => X86
+                            | _ => raise Fail "strange MLton_Platform_Arch_host"
+
+                        val hostIsBigEndian =
+                           _const "MLton_Platform_Arch_bigendian": bool;
+                     end
+
+                  structure OS =
+                     struct
+                        datatype t =
+                           Cygwin
+                         | Darwin
+                         | FreeBSD
+                         | Linux
+                         | MinGW
+                         | NetBSD
+                         | OpenBSD
+                         | Solaris
+
+                        val host: t =
+                           case _const "MLton_Platform_OS_host": string; of
+                              "cygwin" => Cygwin
+                            | "darwin" => Darwin
+                            | "freebsd" => FreeBSD
+                            | "linux" => Linux
+                            | "mingw" => MinGW
+                            | "netbsd" => NetBSD
+                            | "openbsd" => OpenBSD
+                            | "solaris" => Solaris
+                            | _ => raise Fail "strange MLton_Platform_OS_host"
+
+                        val forkIsEnabled =
+                           case host of
+                              Cygwin =>
+                                 #1 _symbol "MLton_Platform_CygwinUseMmap": bool GetSet.t; ()
+                            | MinGW => false
+                            | _ => true
+
+                        val useWindowsProcess = not forkIsEnabled
+                     end
+               end
+
+            structure Process =
+               struct
+                  val spawne =
+                     if let
+                           open Platform.OS
+                        in
+                           case host of
+                              Cygwin => true
+                            | MinGW => true
+                            | _ => false
+                        end
+                        then
+                           _import "MLton_Process_spawne"
+                           : (NullString.t 
+                              * NullString.t array
+                              * NullString.t array
+                              -> Pid.t);
+                        else fn _ => raise Fail "spawne not defined"
+                  val spawnp =
+                     if let
+                           open Platform.OS
+                        in
+                           case host of
+                              Cygwin => true
+                            | MinGW => true
+                            | _ => false
+                        end
+                        then
+                           _import "MLton_Process_spawnp"
+                           : (NullString.t 
+                              * NullString.t array
+                              -> Pid.t);
+                        else fn _ => raise Fail "spawnp not defined"
+               end
+            
+            structure Profile =
+               struct
+                  val isOn = _build_const "MLton_Profile_isOn": bool;
+                  structure Data =
+                     struct
+                        type t = word
+
+                        val dummy:t = 0w0
+                        val free = 
+                           _import "GC_profileFree": GCState.t * t -> unit;
+                        val malloc = 
+                           _import "GC_profileMalloc": GCState.t -> t;
+                        val write = 
+                           _import "GC_profileWrite" 
+                           : GCState.t * t * word (* fd *) -> unit;
+                     end
+                  val done = _import "GC_profileDone": GCState.t -> unit;
+                  val getCurrent = 
+                     _import "GC_getProfileCurrent": GCState.t -> Data.t;
+                  val setCurrent =
+                     _import "GC_setProfileCurrent"
+                     : GCState.t * Data.t -> unit;
+               end
+            
+            structure Rlimit =
+               struct
+                  type rlim = word
+                     
+                  val infinity = _const "MLton_Rlimit_infinity": rlim;
+
+                  type t = int
+
+                  val cpuTime = _const "MLton_Rlimit_cpuTime": t;
+                  val coreFileSize = _const "MLton_Rlimit_coreFileSize": t;
+                  val dataSize = _const "MLton_Rlimit_dataSize": t;
+                  val fileSize = _const "MLton_Rlimit_fileSize": t;
+                  val lockedInMemorySize =
+                     _const "MLton_Rlimit_lockedInMemorySize": t;
+                  val numFiles = _const "MLton_Rlimit_numFiles": t;
+                  val numProcesses = _const "MLton_Rlimit_numProcesses": t;
+                  val residentSetSize = _const "MLton_Rlimit_residentSetSize": t;
+                  val stackSize = _const "MLton_Rlimit_stackSize": t;
+                  val virtualMemorySize =
+                     _const "MLton_Rlimit_virtualMemorySize": t;
+                     
+                  val get = _import "MLton_Rlimit_get": t -> int;
+                  val getHard = _import "MLton_Rlimit_getHard": unit -> rlim;
+                  val getSoft = _import "MLton_Rlimit_getSoft": unit -> rlim;
+                  val set = _import "MLton_Rlimit_set": t * rlim * rlim -> int;
+               end
+            
+            structure Rusage =
+               struct
+                 val ru = _import "MLton_Rusage_ru": unit -> unit;
+                    
+                 val self_utime_sec = _import "MLton_Rusage_self_utime_sec": unit -> int;
+                 val self_utime_usec = _import "MLton_Rusage_self_utime_usec": unit -> int;
+                 val self_stime_sec = _import "MLton_Rusage_self_stime_sec": unit -> int;
+                 val self_stime_usec = _import "MLton_Rusage_self_stime_usec": unit -> int;
+                 val children_utime_sec = _import "MLton_Rusage_children_utime_sec": unit -> int;
+                 val children_utime_usec = _import "MLton_Rusage_children_utime_usec": unit -> int;
+                 val children_stime_sec = _import "MLton_Rusage_children_stime_sec": unit -> int;
+                 val children_stime_usec = _import "MLton_Rusage_children_stime_usec": unit -> int;
+                 val gc_utime_sec = _import "MLton_Rusage_gc_utime_sec": unit -> int;
+                 val gc_utime_usec = _import "MLton_Rusage_gc_utime_usec": unit -> int;
+                 val gc_stime_sec = _import "MLton_Rusage_gc_stime_sec": unit -> int;
+                 val gc_stime_usec = _import "MLton_Rusage_gc_stime_usec": unit -> int;
+               end
+
+            structure Syslog =
+               struct
+                  type openflag = int
+                     
+                  val CONS = _const "LOG_CONS": openflag;
+                  val NDELAY = _const "LOG_NDELAY": openflag;
+                  val PERROR = _const "LOG_PERROR": openflag;
+                  val PID = _const "LOG_PID": openflag;
+                     
+                  type facility = int
+                     
+                  val AUTHPRIV = _const "LOG_AUTHPRIV": facility;
+                  val CRON = _const "LOG_CRON": facility;
+                  val DAEMON = _const "LOG_DAEMON": facility;
+                  val KERN = _const "LOG_KERN": facility;
+                  val LOCAL0 = _const "LOG_LOCAL0": facility;
+                  val LOCAL1 = _const "LOG_LOCAL1": facility;
+                  val LOCAL2 = _const "LOG_LOCAL2": facility;
+                  val LOCAL3 = _const "LOG_LOCAL3": facility;
+                  val LOCAL4 = _const "LOG_LOCAL4": facility;
+                  val LOCAL5 = _const "LOG_LOCAL5": facility;
+                  val LOCAL6 = _const "LOG_LOCAL6": facility;
+                  val LOCAL7 = _const "LOG_LOCAL7": facility;
+                  val LPR = _const "LOG_LPR": facility;
+                  val MAIL = _const "LOG_MAIL": facility;
+                  val NEWS = _const "LOG_NEWS": facility;
+                  val SYSLOG = _const "LOG_SYSLOG": facility;
+                  val USER = _const "LOG_USER": facility;
+                  val UUCP = _const "LOG_UUCP": facility;
+                     
+                  type loglevel = int
+                     
+                  val EMERG = _const "LOG_EMERG": loglevel;
+                  val ALERT = _const "LOG_ALERT": loglevel;
+                  val CRIT = _const "LOG_CRIT": loglevel;
+                  val ERR = _const "LOG_ERR": loglevel;
+                  val WARNING = _const "LOG_WARNING": loglevel;
+                  val NOTICE = _const "LOG_NOTICE": loglevel;
+                  val INFO = _const "LOG_INFO": loglevel;
+                  val DEBUG = _const "LOG_DEBUG": loglevel;
+               end
+
+            structure Weak =
+               struct
+                  open Weak
+                     
+                  val canGet = _prim "Weak_canGet": 'a t -> bool;
+                  val get = _prim "Weak_get": 'a t -> 'a;
+                  val new = _prim "Weak_new": 'a -> 'a t;
+               end
+         end
+
+      structure Net =
+         struct
+            (* val htonl = _import "Net_htonl": int -> int; *)
+            (* val ntohl = _import "Net_ntohl": int -> int; *)
+            val htons = _import "Net_htons": int -> int;
+            val ntohs = _import "Net_ntohs": int -> int;
+         end
+
+      structure NetHostDB =
+         struct
+            (* network byte order (MSB) *)
+            type pre_in_addr = Word8.word array
+            type in_addr = Word8.word vector
+            val inAddrLen = _const "NetHostDB_inAddrLen": int;
+            val INADDR_ANY = _const "NetHostDB_INADDR_ANY": int;
+            type addr_family = int
+            val entryName = _import "NetHostDB_Entry_name": unit -> CString.t;
+            val entryNumAliases = _import "NetHostDB_Entry_numAliases": unit -> int;
+            val entryAliasesN = _import "NetHostDB_Entry_aliasesN": int -> CString.t;
+            val entryAddrType = _import "NetHostDB_Entry_addrType": unit -> int;
+            val entryLength = _import "NetHostDB_Entry_length": unit -> int;
+            val entryNumAddrs = _import "NetHostDB_Entry_numAddrs": unit -> int;
+            val entryAddrsN =
+               _import "NetHostDB_Entry_addrsN": int * pre_in_addr -> unit;
+            val getByAddress =
+               _import "NetHostDB_getByAddress": in_addr * int -> bool;
+            val getByName = _import "NetHostDB_getByName": NullString.t -> bool;
+            val getHostName =
+               _import "NetHostDB_getHostName": char array * int -> int;
+         end
+
+      structure NetProtDB =
+         struct
+            val entryName = _import "NetProtDB_Entry_name": unit -> CString.t;
+            val entryNumAliases = _import "NetProtDB_Entry_numAliases": unit -> int;
+            val entryAliasesN = _import "NetProtDB_Entry_aliasesN": int -> CString.t;
+            val entryProtocol = _import "NetProtDB_Entry_protocol": unit -> int;
+            val getByName = _import "NetProtDB_getByName": NullString.t -> bool;
+            val getByNumber = _import "NetProtDB_getByNumber": int -> bool;
+         end
+
+      structure NetServDB =
+         struct
+            val entryName = _import "NetServDB_Entry_name": unit -> CString.t;
+            val entryNumAliases = _import "NetServDB_Entry_numAliases": unit -> int;
+            val entryAliasesN = _import "NetServDB_Entry_aliasesN": int -> CString.t;
+            val entryPort = _import "NetServDB_Entry_port": unit -> int;
+            val entryProtocol = _import "NetServDB_Entry_protocol": unit -> CString.t;
+            val getByName = _import "NetServDB_getByName": NullString.t * NullString.t -> bool;
+            val getByNameNull = _import "NetServDB_getByNameNull": NullString.t -> bool;
+            val getByPort = _import "NetServDB_getByPort": int * NullString.t -> bool;
+            val getByPortNull = _import "NetServDB_getByPortNull": int -> bool;
+         end
+
+      structure OS =
+         struct
+            structure IO =
+               struct
+                  val POLLIN = _const "OS_IO_POLLIN": word;
+                  val POLLPRI = _const "OS_IO_POLLPRI": word;
+                  val POLLOUT = _const "OS_IO_POLLOUT": word;
+                  val poll = _import "OS_IO_poll": int vector * word vector * 
+                                                int * int * word array -> int;
+               end
+         end
+
+      structure PackReal32 =
+         struct
+            type real = Real32.real
+               
+            val subVec = _import "PackReal32_subVec": Word8.word vector * int -> real;
+            val subVecRev =
+               _import "PackReal32_subVecRev": Word8.word vector * int -> real;
+            val update =
+               _import "PackReal32_update": Word8.word array * int * real -> unit;
+            val updateRev =
+               _import "PackReal32_updateRev": Word8.word array * int * real -> unit;
+         end
+
+      structure PackReal64 =
+         struct
+            type real = Real64.real
+               
+            val subVec = _import "PackReal64_subVec": Word8.word vector * int -> real;
+            val subVecRev =
+               _import "PackReal64_subVecRev": Word8.word vector * int -> real;
+            val update =
+               _import "PackReal64_update": Word8.word array * int * real -> unit;
+            val updateRev =
+               _import "PackReal64_updateRev": Word8.word array * int * real -> unit;
+         end
+
+      structure Pointer =
+         struct
+            open Pointer
+
+            val fromWord = _prim "WordU32_toWord32": word -> t;
+            val toWord = _prim "WordU32_toWord32": t -> word;
+               
+            val null: t = fromWord 0w0
+
+            fun isNull p = p = null
+
+            (* val + = _prim "Pointer_add": t * t -> t; *)
+            (* val op < = _prim "Pointer_lt": t * t -> bool; *)
+            (* val - = _prim "Pointer_sub": t * t -> t; *)
+(*            val free = _import "free": t -> unit; *)
+            val getInt8 = _prim "Pointer_getWord8": t * int -> Int8.int;
+            val getInt16 = _prim "Pointer_getWord16": t * int -> Int16.int;
+            val getInt32 = _prim "Pointer_getWord32": t * int -> Int32.int;
+            val getInt64 = _prim "Pointer_getWord64": t * int -> Int64.int;
+            val getPointer = _prim "Pointer_getPointer": t * int -> 'a;
+            val getReal32 = _prim "Pointer_getReal32": t * int -> Real32.real;
+            val getReal64 = _prim "Pointer_getReal64": t * int -> Real64.real;
+            val getWord8 = _prim "Pointer_getWord8": t * int -> Word8.word;
+            val getWord16 = _prim "Pointer_getWord16": t * int -> Word16.word;
+            val getWord32 = _prim "Pointer_getWord32": t * int -> Word32.word;
+            val getWord64 = _prim "Pointer_getWord64": t * int -> Word64.word;
+            val setInt8 = _prim "Pointer_setWord8": t * int * Int8.int -> unit;
+            val setInt16 =
+               _prim "Pointer_setWord16": t * int * Int16.int -> unit;
+            val setInt32 =
+               _prim "Pointer_setWord32": t * int * Int32.int -> unit;
+            val setInt64 = 
+               _prim "Pointer_setWord64": t * int * Int64.int -> unit;
+            val setPointer = _prim "Pointer_setPointer": t * int * 'a -> unit;
+            val setReal32 =
+               _prim "Pointer_setReal32": t * int * Real32.real -> unit;
+            val setReal64 =
+               _prim "Pointer_setReal64": t * int * Real64.real -> unit;
+            val setWord8 =
+               _prim "Pointer_setWord8": t * int * Word8.word -> unit;
+            val setWord16 =
+               _prim "Pointer_setWord16": t * int * Word16.word -> unit;
+            val setWord32 =
+               _prim "Pointer_setWord32": t * int * Word32.word -> unit;
+            val setWord64 =
+               _prim "Pointer_setWord64": t * int * Word64.word -> unit;
+         end
+
+      structure Real64 =
+         struct
+            open Real64
+
+            structure Class =
+               struct
+                  type t = int
+                     
+                  val inf = _const "FP_INFINITE": t;
+                  val nan = _const "FP_NAN": t;
+                  val normal = _const "FP_NORMAL": t;
+                  val subnormal = _const "FP_SUBNORMAL": t;
+                  val zero = _const "FP_ZERO": t;
+               end
+            
+            structure Math =
+               struct
+                  type real = real
+
+                  val acos = _prim "Real64_Math_acos": real -> real;
+                  val asin = _prim "Real64_Math_asin": real -> real;
+                  val atan = _prim "Real64_Math_atan": real -> real;
+                  val atan2 = _prim "Real64_Math_atan2": real * real -> real;
+                  val cos = _prim "Real64_Math_cos": real -> real;
+                  val cosh = _import "cosh": real -> real;
+                  val e = #1 _symbol "Real64_Math_e": real GetSet.t; ()
+                  val exp = _prim "Real64_Math_exp": real -> real;
+                  val ln = _prim "Real64_Math_ln": real -> real;
+                  val log10 = _prim "Real64_Math_log10": real -> real;
+                  val pi = #1 _symbol "Real64_Math_pi": real GetSet.t; ()
+                  val pow = _import "pow": real * real -> real;
+                  val sin = _prim "Real64_Math_sin": real -> real;
+                  val sinh = _import "sinh": real -> real;
+                  val sqrt = _prim "Real64_Math_sqrt": real -> real;
+                  val tan = _prim "Real64_Math_tan": real -> real;
+                  val tanh = _import "tanh": real -> real;
+               end
+
+            val * = _prim "Real64_mul": real * real -> real;
+            val *+ = _prim "Real64_muladd": real * real * real -> real;
+            val *- = _prim "Real64_mulsub": real * real * real -> real;
+            val + = _prim "Real64_add": real * real -> real;
+            val - = _prim "Real64_sub": real * real -> real;
+            val / = _prim "Real64_div": real * real -> real;
+            val op < = _prim "Real64_lt": real * real -> bool;
+            val op <= = _prim "Real64_le": real * real -> bool;
+            val == = _prim "Real64_equal": real * real -> bool;
+            val ?= = _prim "Real64_qequal": real * real -> bool;
+            val abs = _prim "Real64_abs": real -> real;
+            val class = _import "Real64_class": real -> int;
+            val frexp = _import "Real64_frexp": real * int ref -> real;
+            val gdtoa =
+               _import "Real64_gdtoa": real * int * int * int ref -> CString.t;
+            val fromInt = _prim "WordS32_toReal64": int -> real;
+            val ldexp = _prim "Real64_ldexp": real * int -> real;
+            val maxFinite = #1 _symbol "Real64_maxFinite": real GetSet.t; ()
+            val minNormalPos = #1 _symbol "Real64_minNormalPos": real GetSet.t; ()
+            val minPos = #1 _symbol "Real64_minPos": real GetSet.t; ()
+            val modf = _import "Real64_modf": real * real ref -> real;
+            val nextAfter = _import "Real64_nextAfter": real * real -> real;
+            val round = _prim "Real64_round": real -> real;
+            val signBit = _import "Real64_signBit": real -> int;
+            val strto = _import "Real64_strto": NullString.t -> real;
+            val toInt = _prim "Real64_toWordS32": real -> int;
+            val ~ = _prim "Real64_neg": real -> real;
+
+            val fromLarge : real -> real = fn x => x
+            val toLarge : real -> real = fn x => x
+            val precision : int = 53
+            val radix : int = 2
+         end
+      
+      structure Real32 =
+         struct
+            open Real32
+
+            val precision : int = 24
+            val radix : int = 2
+
+            val fromLarge = _prim "Real64_toReal32": Real64.real -> real;
+            val toLarge = _prim "Real32_toReal64": real -> Real64.real;
+
+            fun unary (f: Real64.real -> Real64.real) (r: real): real =
+               fromLarge (f (toLarge r))
+
+            fun binary (f: Real64.real * Real64.real -> Real64.real)
+               (r: real, r': real): real =
+               fromLarge (f (toLarge r, toLarge r'))
+               
+            structure Math =
+               struct
+                  type real = real
+
+                  val acos = _prim "Real32_Math_acos": real -> real;
+                  val asin = _prim "Real32_Math_asin": real -> real;
+                  val atan = _prim "Real32_Math_atan": real -> real;
+                  val atan2 = _prim "Real32_Math_atan2": real * real -> real;
+                  val cos = _prim "Real32_Math_cos": real -> real;
+                  val cosh = unary Real64.Math.cosh
+                  val e = #1 _symbol "Real32_Math_e": real GetSet.t; ()
+                  val exp = _prim "Real32_Math_exp": real -> real;
+                  val ln = _prim "Real32_Math_ln": real -> real;
+                  val log10 = _prim "Real32_Math_log10": real -> real;
+                  val pi = #1 _symbol "Real32_Math_pi": real GetSet.t; ()
+                  val pow = binary Real64.Math.pow
+                  val sin = _prim "Real32_Math_sin": real -> real;
+                  val sinh = unary Real64.Math.sinh
+                  val sqrt = _prim "Real32_Math_sqrt": real -> real;
+                  val tan = _prim "Real32_Math_tan": real -> real;
+                  val tanh = unary Real64.Math.tanh
+               end
+
+            val * = _prim "Real32_mul": real * real -> real;
+            val *+ = _prim "Real32_muladd": real * real * real -> real;
+            val *- = _prim "Real32_mulsub": real * real * real -> real;
+            val + = _prim "Real32_add": real * real -> real;
+            val - = _prim "Real32_sub": real * real -> real;
+            val / = _prim "Real32_div": real * real -> real;
+            val op < = _prim "Real32_lt": real * real -> bool;
+            val op <= = _prim "Real32_le": real * real -> bool;
+            val == = _prim "Real32_equal": real * real -> bool;
+            val ?= = _prim "Real32_qequal": real * real -> bool;
+            val abs = _prim "Real32_abs": real -> real;
+            val class = _import "Real32_class": real -> int;
+            fun frexp (r: real, ir: int ref): real =
+               fromLarge (Real64.frexp (toLarge r, ir))
+            val gdtoa =
+               _import "Real32_gdtoa": real * int * int * int ref -> CString.t;
+            val fromInt = _prim "WordS32_toReal32": int -> real;
+            val ldexp = _prim "Real32_ldexp": real * int -> real;
+            val maxFinite = #1 _symbol "Real32_maxFinite": real GetSet.t; ()
+            val minNormalPos = #1 _symbol "Real32_minNormalPos": real GetSet.t; ()
+            val minPos = #1 _symbol "Real32_minPos": real GetSet.t; ()
+            val modf = _import "Real32_modf": real * real ref -> real;
+            val signBit = _import "Real32_signBit": real -> int;
+            val strto = _import "Real32_strto": NullString.t -> real;
+            val toInt = _prim "Real32_toWordS32": real -> int;
+            val ~ = _prim "Real32_neg": real -> real;
+         end
+    
+      structure Real32 =
+         struct
+            open Real32
+            local
+               structure S = RealComparisons (Real32)
+            in
+               open S
+            end
+         end
+
+      structure Real64 =
+         struct
+            open Real64
+            local
+               structure S = RealComparisons (Real64)
+            in
+               open S
+            end
+         end
+
+      structure Ref =
+         struct
+            val deref = _prim "Ref_deref": 'a ref -> 'a;
+            val assign = _prim "Ref_assign": 'a ref * 'a -> unit;
+         end
+
+      structure Signal:>
+         sig
+            eqtype t
+            type how
+
+            val fromInt: int -> t
+            val toInt: t -> int
+         end =
+         struct
+            type t = int
+            type how = int
+
+            val fromInt = fn s => s
+            val toInt = fn s => s
+         end
+
+      structure Socket:>
+         sig
+            type sock
+
+            val fromInt: int -> sock
+            val toInt: sock -> int
+         end =
+         struct
+            type sock = int
+
+            fun fromInt i = i
+            fun toInt i = i
+         end
+            
+      structure Socket =
+         struct
+            open Socket
+
+            type pre_sock_addr = Word8.word array
+            type sock_addr = Word8.word vector
+            val sockAddrLenMax = _const "Socket_sockAddrLenMax": int;
+            structure AF =
+               struct
+                  type addr_family = int
+                  val UNIX = _const "Socket_AF_UNIX": addr_family;
+                  val INET = _const "Socket_AF_INET": addr_family;
+                  val INET6 = _const "Socket_AF_INET6": addr_family;
+                  val UNSPEC = _const "Socket_AF_UNSPEC": addr_family;
+               end
+            structure SOCK:>
+               sig
+                  eqtype sock_type
+
+                  val fromInt: int -> sock_type
+               end =
+               struct
+                  type sock_type = int
+
+                  val fromInt = fn i => i
+               end
+            structure SOCK =
+               struct
+                  open SOCK
+                  val STREAM = _const "Socket_SOCK_STREAM": sock_type;
+                  val DGRAM = _const "Socket_SOCK_DGRAM": sock_type;
+               end
+            structure CtlExtra =
+               struct
+                  type level = int
+                  type optname = int
+                  type request = int
+                  (* host byte order (LSB) *)
+                  type read_data = Word8.word vector
+                  type write_data = Word8.word array
+
+                  val setSockOpt = 
+                     _import "Socket_Ctl_setSockOpt": sock * level * optname * 
+                                                   read_data * int -> 
+                                                   int;
+                  val getSockOpt = 
+                     _import "Socket_Ctl_getSockOpt": sock * level * optname * 
+                                                   write_data * int ref -> 
+                                                   int;
+                  val setIOCtl =
+                     _import "Socket_Ctl_getsetIOCtl": sock * request *
+                                                    read_data ->
+                                                    int;
+                  val getIOCtl =
+                     _import "Socket_Ctl_getsetIOCtl": sock * request *
+                                                    write_data ->
+                                                    int;
+               end
+            structure Ctl =
+               struct
+                  open CtlExtra
+                  val SOCKET = _const "Socket_Ctl_SOL_SOCKET": level;
+                  val DEBUG = _const "Socket_Ctl_SO_DEBUG": optname;
+                  val REUSEADDR = _const "Socket_Ctl_SO_REUSEADDR": optname;
+                  val KEEPALIVE = _const "Socket_Ctl_SO_KEEPALIVE": optname;
+                  val DONTROUTE = _const "Socket_Ctl_SO_DONTROUTE": optname;
+                  val LINGER = _const "Socket_Ctl_SO_LINGER": optname;
+                  val BROADCAST = _const "Socket_Ctl_SO_BROADCAST": optname;
+                  val OOBINLINE = _const "Socket_Ctl_SO_OOBINLINE": optname;
+                  val SNDBUF = _const "Socket_Ctl_SO_SNDBUF": optname;
+                  val RCVBUF = _const "Socket_Ctl_SO_RCVBUF": optname;
+                  val TYPE = _const "Socket_Ctl_SO_TYPE": optname;
+                  val ERROR = _const "Socket_Ctl_SO_ERROR": optname;
+
+                  val getPeerName =
+                     _import "Socket_Ctl_getPeerName": sock * pre_sock_addr * int ref -> int;
+                  val getSockName =
+                     _import "Socket_Ctl_getSockName": sock * pre_sock_addr * int ref -> int;
+
+                  (* val NBIO = _const "Socket_Ctl_FIONBIO": request; *)
+                  val NREAD = _const "Socket_Ctl_FIONREAD": request;
+                  val ATMARK = _const "Socket_Ctl_SIOCATMARK": request;
+               end
+
+            val familyOfAddr =
+               _import "Socket_familyOfAddr": sock_addr -> AF.addr_family;
+            val bind = _import "Socket_bind": sock * sock_addr * int -> int;
+            val listen = _import "Socket_listen": sock * int -> int;
+            val connect =
+               _import "Socket_connect": sock * sock_addr * int -> int;
+            val accept =
+               _import "Socket_accept": sock * pre_sock_addr * int ref -> int;
+            val close = _import "Socket_close": sock -> int;
+
+            type how = int
+            val SHUT_RD = _const "Socket_SHUT_RD": how;
+            val SHUT_WR = _const "Socket_SHUT_WR": how;
+            val SHUT_RDWR = _const "Socket_SHUT_RDWR": how;
+            val shutdown = _import "Socket_shutdown": sock * how -> int;
+
+            type flags = word
+            val MSG_DONTROUTE = _const "Socket_MSG_DONTROUTE": flags;
+            val MSG_DONTWAIT = _const "Socket_MSG_DONTWAIT": flags;
+            val MSG_OOB = _const "Socket_MSG_OOB": flags;
+            val MSG_PEEK = _const "Socket_MSG_PEEK": flags;
+
+            val sendArr = _import "Socket_send":
+               sock * Word8.word array * int * int * word -> int;
+            val sendVec = _import "Socket_send":
+               sock * Word8.word vector * int * int * word -> int;
+            val sendToArr = _import "Socket_sendTo":
+               sock * Word8.word array * int * int * word * sock_addr * int -> int;
+            val sendToVec = _import "Socket_sendTo":
+               sock * Word8.word vector * int * int * word * sock_addr * int -> int;
+            val recv = _import "Socket_recv":
+               sock * Word8.word array * int * int * word -> int;
+            val recvFrom = _import "Socket_recvFrom":
+               sock * Word8.word array * int * int * word * pre_sock_addr * int ref
+               -> int;
+
+            structure GenericSock =
+               struct
+                  val socket = 
+                     _import "GenericSock_socket": AF.addr_family * 
+                                                SOCK.sock_type * 
+                                                int -> int;
+                  val socketPair = 
+                     _import "GenericSock_socketPair": AF.addr_family * 
+                                                    SOCK.sock_type * 
+                                                    int * 
+                                                    int ref * int ref -> int;
+               end
+
+            structure INetSock =
+               struct
+                  val toAddr = _import "INetSock_toAddr": NetHostDB.in_addr * int * 
+                                                       pre_sock_addr * int ref -> unit;
+                  val fromAddr = _import "INetSock_fromAddr": sock_addr -> unit;
+                  val getInAddr = _import "INetSock_getInAddr": NetHostDB.pre_in_addr -> 
+                                                             unit;
+                  val getPort = _import "INetSock_getPort": unit -> int;
+                  structure TCP =
+                     struct
+                        open CtlExtra
+                        val TCP = _const "Socket_INetSock_TCP_SOL_TCP": level;
+                        val NODELAY = _const "Socket_INetSock_TCP_SO_NODELAY": optname;
+                     end
+               end
+            structure UnixSock =
+               struct
+                  val toAddr =
+                     _import "UnixSock_toAddr"
+                     : NullString.t * int * pre_sock_addr * int ref -> unit;
+                  val pathLen = _import "UnixSock_pathLen": sock_addr -> int;
+                  val fromAddr =
+                     _import "UnixSock_fromAddr"
+                     : sock_addr * char array * int -> unit;
+               end
+         end
+
+      structure Status:>
+         sig
+            eqtype t
+
+            val failure: t
+            val fromInt: int -> t
+            val success: t
+            val toInt: t -> int
+         end =
+         struct
+            type t = int
+
+            val failure = 1
+            val fromInt = fn i => i
+            val success = 0
+            val toInt = fn i => i
+         end
+
+      val halt = _prim "MLton_halt": Status.t -> unit;
+
+      structure String =
+         struct
+            val fromWord8Vector =
+               _prim "Word8Vector_toString": Word8.word vector -> string;
+            val toWord8Vector =
+               _prim "String_toWord8Vector": string -> Word8.word vector;
+         end
+
+      structure TextIO =
+         struct
+            val bufSize = _command_line_const "TextIO.bufSize": int = 4096;
+         end
+      
+      structure Thread =
+         struct
+            type preThread = PreThread.t
+            type thread = Thread.t
+
+            val atomicBegin = _prim "Thread_atomicBegin": unit -> unit;
+            val canHandle = _prim "Thread_canHandle": unit -> int;
+            fun atomicEnd () =
+               if Int.<= (canHandle (), 0)
+                  then raise Fail "Thread.atomicEnd with no atomicBegin"
+               else _prim "Thread_atomicEnd": unit -> unit; ()
+            val copy = _prim "Thread_copy": preThread -> thread;
+            (* copyCurrent's result is accesible via savedPre ().
+             * It is not possible to have the type of copyCurrent as
+             * unit -> preThread, because there are two different ways to
+             * return from the call to copyCurrent.  One way is the direct
+             * obvious way, in the thread that called copyCurrent.  That one,
+             * of course, wants to call savedPre ().  However, another way to
+             * return is by making a copy of the preThread and then switching
+             * to it.  In that case, there is no preThread to return.  Making
+             * copyCurrent return a preThread creates nasty bugs where the
+             * return code from the CCall expects to see a preThread result
+             * according to the C return convention, but there isn't one when
+             * switching to a copy.
+             *)
+            val copyCurrent = _prim "Thread_copyCurrent": unit -> unit;
+            val current = _import "GC_getCurrentThread": GCState.t -> thread;
+            val finishSignalHandler = _import "GC_finishSignalHandler": GCState.t -> unit;
+            val returnToC = _prim "Thread_returnToC": unit -> unit;
+            val saved = _import "GC_getSavedThread": GCState.t -> thread;
+            val savedPre = _import "GC_getSavedThread": GCState.t -> preThread;
+            val setCallFromCHandler =
+               _import "GC_setCallFromCHandlerThread": GCState.t * thread -> unit;
+            val setSignalHandler = _import "GC_setSignalHandlerThread": GCState.t * thread -> unit;
+            val setSaved = _import "GC_setSavedThread": GCState.t * thread -> unit;
+            val startSignalHandler = _import "GC_startSignalHandler": GCState.t -> unit;
+            val switchTo = _prim "Thread_switchTo": thread -> unit;
+         end      
+
+      structure Time =
+         struct
+            val gettimeofday = _import "Time_gettimeofday": unit -> int;
+            val sec = _import "Time_sec": unit -> int;
+            val usec = _import "Time_usec": unit -> int;
+         end
+
+      structure TopLevel =
+         struct
+            val setHandler =
+               _prim "TopLevel_setHandler": (exn -> unit) -> unit;
+            val setSuffix =
+               _prim "TopLevel_setSuffix": (unit -> unit) -> unit;
+         end
+
+      structure Vector =
+         struct
+            val sub = _prim "Vector_sub": 'a vector * int -> 'a;
+            val length = _prim "Vector_length": 'a vector -> int;
+
+            (* Don't mutate the array after you apply fromArray, because vectors
+             * are supposed to be immutable and the optimizer depends on this.
+             *)
+            val fromArray = _prim "Array_toVector": 'a array -> 'a vector;
+         end
+
+      structure Word1 =
+         struct
+            open Word1
+            type big = Word8.word
+            val fromBigUnsafe = _prim "WordU8_toWord1": big -> word;
+            val toBig = _prim "WordU1_toWord8": word -> big;
+            val wordSize = 1
+         end
+      structure Word2 =
+         struct
+            open Word2
+            type big = Word8.word
+            val fromBigUnsafe = _prim "WordU8_toWord2": big -> word;
+            val toBig = _prim "WordU2_toWord8": word -> big;
+            val wordSize = 2
+         end
+      structure Word3 =
+         struct
+            open Word3
+            type big = Word8.word
+            val fromBigUnsafe = _prim "WordU8_toWord3": big -> word;
+            val toBig = _prim "WordU3_toWord8": word -> big;
+            val wordSize = 3
+         end
+      structure Word4 =
+         struct
+            open Word4
+            type big = Word8.word
+            val fromBigUnsafe = _prim "WordU8_toWord4": big -> word;
+            val toBig = _prim "WordU4_toWord8": word -> big;
+            val wordSize = 4
+         end
+      structure Word5 =
+         struct
+            open Word5
+            type big = Word8.word
+            val fromBigUnsafe = _prim "WordU8_toWord5": big -> word;
+            val toBig = _prim "WordU5_toWord8": word -> big;
+            val wordSize = 5
+         end
+      structure Word6 =
+         struct
+            open Word6
+            type big = Word8.word
+            val fromBigUnsafe = _prim "WordU8_toWord6": big -> word;
+            val toBig = _prim "WordU6_toWord8": word -> big;
+            val wordSize = 6
+         end
+      structure Word7 =
+         struct
+            open Word7
+            type big = Word8.word
+            val fromBigUnsafe = _prim "WordU8_toWord7": big -> word;
+            val toBig = _prim "WordU7_toWord8": word -> big;
+            val wordSize = 7
+         end
+      structure Word8 =
+         struct
+            open Word8
+               
+            val wordSize: int = 8
+
+            val + = _prim "Word8_add": word * word -> word;
+            val andb = _prim "Word8_andb": word * word -> word;
+            val ~>> = _prim "WordS8_rshift": word * Word.word -> word;
+            val div = _prim "WordU8_quot": word * word -> word;
+            val fromInt = _prim "WordU32_toWord8": int -> word;
+            val fromLarge = _prim "WordU64_toWord8": LargeWord.word -> word;
+            val << = _prim "Word8_lshift": word * Word.word -> word;
+            val op < = _prim "WordU8_lt": word * word -> bool;
+            val mod = _prim "WordU8_rem": word * word -> word;
+            val * = _prim "WordU8_mul": word * word -> word;
+            val ~ = _prim "Word8_neg": word -> word;
+            val notb = _prim "Word8_notb": word -> word;
+            val orb = _prim "Word8_orb": word * word -> word;
+            val rol = _prim "Word8_rol": word * Word.word -> word;
+            val ror = _prim "Word8_ror": word * Word.word -> word;
+            val >> = _prim "WordU8_rshift": word * Word.word -> word;
+            val - = _prim "Word8_sub": word * word -> word;
+            val toInt = _prim "WordU8_toWord32": word -> int;
+            val toIntX = _prim "WordS8_toWord32": word -> int;
+            val toLarge = _prim "WordU8_toWord64": word -> LargeWord.word;
+            val toLargeX = _prim "WordS8_toWord64": word -> LargeWord.word;
+            val xorb = _prim "Word8_xorb": word * word -> word;
+         end
+      structure Word8 =
+         struct
+            open Word8
+            local
+               structure S = Comparisons (Word8)
+            in
+               open S
+            end
+         end
+      structure Word8Array =
+         struct
+            val subWord =
+               _prim "Word8Array_subWord": Word8.word array * int -> word;
+            val subWordRev =
+               _import "Word8Array_subWord32Rev": Word8.word array * int -> word;
+            val updateWord =
+               _prim "Word8Array_updateWord": Word8.word array * int * word -> unit;
+            val updateWordRev =
+               _import "Word8Array_updateWord32Rev": Word8.word array * int * word -> unit;
+         end
+      structure Word8Vector =
+         struct
+            val subWord =
+               _prim "Word8Vector_subWord": Word8.word vector * int -> word;
+            val subWordRev =
+               _import "Word8Vector_subWord32Rev": Word8.word vector * int -> word;
+         end
+      structure Word9 =
+         struct
+            open Word9
+            type big = Word16.word
+            val fromBigUnsafe = _prim "WordU16_toWord9": big -> word;
+            val toBig = _prim "WordU9_toWord16": word -> big;
+            val wordSize = 9
+         end
+      structure Word10 =
+         struct
+            open Word10
+            type big = Word16.word
+            val fromBigUnsafe = _prim "WordU16_toWord10": big -> word;
+            val toBig = _prim "WordU10_toWord16": word -> big;
+            val wordSize = 10
+         end
+      structure Word11 =
+         struct
+            open Word11
+            type big = Word16.word
+            val fromBigUnsafe = _prim "WordU16_toWord11": big -> word;
+            val toBig = _prim "WordU11_toWord16": word -> big;
+            val wordSize = 11
+         end
+      structure Word12 =
+         struct
+            open Word12
+            type big = Word16.word
+            val fromBigUnsafe = _prim "WordU16_toWord12": big -> word;
+            val toBig = _prim "WordU12_toWord16": word -> big;
+            val wordSize = 12
+         end
+      structure Word13 =
+         struct
+            open Word13
+            type big = Word16.word
+            val fromBigUnsafe = _prim "WordU16_toWord13": big -> word;
+            val toBig = _prim "WordU13_toWord16": word -> big;
+            val wordSize = 13
+         end
+      structure Word14 =
+         struct
+            open Word14
+            type big = Word16.word
+            val fromBigUnsafe = _prim "WordU16_toWord14": big -> word;
+            val toBig = _prim "WordU14_toWord16": word -> big;
+            val wordSize = 14
+         end
+      structure Word15 =
+         struct
+            open Word15
+            type big = Word16.word
+            val fromBigUnsafe = _prim "WordU16_toWord15": big -> word;
+            val toBig = _prim "WordU15_toWord16": word -> big;
+            val wordSize = 15
+         end
+      structure Word16 =
+         struct
+            open Word16
+               
+            val wordSize: int = 16
+
+            val + = _prim "Word16_add": word * word -> word;
+            val andb = _prim "Word16_andb": word * word -> word;
+            val ~>> = _prim "WordS16_rshift": word * Word.word -> word;
+            val div = _prim "WordU16_quot": word * word -> word;
+            val fromInt = _prim "WordU32_toWord16": int -> word;
+            val fromLarge = _prim "WordU64_toWord16": LargeWord.word -> word;
+            val << = _prim "Word16_lshift": word * Word.word -> word;
+            val op < = _prim "WordU16_lt": word * word -> bool;
+            val mod = _prim "WordU16_rem": word * word -> word;
+            val * = _prim "WordU16_mul": word * word -> word;
+            val ~ = _prim "Word16_neg": word -> word;
+            val notb = _prim "Word16_notb": word -> word;
+            val orb = _prim "Word16_orb": word * word -> word;
+            val >> = _prim "WordU16_rshift": word * Word.word -> word;
+            val - = _prim "Word16_sub": word * word -> word;
+            val toInt = _prim "WordU16_toWord32": word -> int;
+            val toIntX = _prim "WordS16_toWord32": word -> int;
+            val toLarge = _prim "WordU16_toWord64": word -> LargeWord.word;
+            val toLargeX = _prim "WordS16_toWord64": word -> LargeWord.word;
+            val xorb = _prim "Word16_xorb": word * word -> word;
+         end
+      structure Word16 =
+         struct
+            open Word16
+            local
+               structure S = Comparisons (Word16)
+            in
+               open S
+            end
+         end
+      structure Word17 =
+         struct
+            open Word17
+            type big = Word32.word
+            val fromBigUnsafe = _prim "WordU32_toWord17": big -> word;
+            val toBig = _prim "WordU17_toWord32": word -> big;
+            val wordSize = 17
+         end
+      structure Word18 =
+         struct
+            open Word18
+            type big = Word32.word
+            val fromBigUnsafe = _prim "WordU32_toWord18": big -> word;
+            val toBig = _prim "WordU18_toWord32": word -> big;
+            val wordSize = 18
+         end
+      structure Word19 =
+         struct
+            open Word19
+            type big = Word32.word
+            val fromBigUnsafe = _prim "WordU32_toWord19": big -> word;
+            val toBig = _prim "WordU19_toWord32": word -> big;
+            val wordSize = 19
+         end
+      structure Word20 =
+         struct
+            open Word20
+            type big = Word32.word
+            val fromBigUnsafe = _prim "WordU32_toWord20": big -> word;
+            val toBig = _prim "WordU20_toWord32": word -> big;
+            val wordSize = 20
+         end
+      structure Word21 =
+         struct
+            open Word21
+            type big = Word32.word
+            val fromBigUnsafe = _prim "WordU32_toWord21": big -> word;
+            val toBig = _prim "WordU21_toWord32": word -> big;
+            val wordSize = 21
+         end
+      structure Word22 =
+         struct
+            open Word22
+            type big = Word32.word
+            val fromBigUnsafe = _prim "WordU32_toWord22": big -> word;
+            val toBig = _prim "WordU22_toWord32": word -> big;
+            val wordSize = 22
+         end
+      structure Word23 =
+         struct
+            open Word23
+            type big = Word32.word
+            val fromBigUnsafe = _prim "WordU32_toWord23": big -> word;
+            val toBig = _prim "WordU23_toWord32": word -> big;
+            val wordSize = 23
+         end
+      structure Word24 =
+         struct
+            open Word24
+            type big = Word32.word
+            val fromBigUnsafe = _prim "WordU32_toWord24": big -> word;
+            val toBig = _prim "WordU24_toWord32": word -> big;
+            val wordSize = 24
+         end
+      structure Word25 =
+         struct
+            open Word25
+            type big = Word32.word
+            val fromBigUnsafe = _prim "WordU32_toWord25": big -> word;
+            val toBig = _prim "WordU25_toWord32": word -> big;
+            val wordSize = 25
+         end
+      structure Word26 =
+         struct
+            open Word26
+            type big = Word32.word
+            val fromBigUnsafe = _prim "WordU32_toWord26": big -> word;
+            val toBig = _prim "WordU26_toWord32": word -> big;
+            val wordSize = 26
+         end
+      structure Word27 =
+         struct
+            open Word27
+            type big = Word32.word
+            val fromBigUnsafe = _prim "WordU32_toWord27": big -> word;
+            val toBig = _prim "WordU27_toWord32": word -> big;
+            val wordSize = 27
+         end
+      structure Word28 =
+         struct
+            open Word28
+            type big = Word32.word
+            val fromBigUnsafe = _prim "WordU32_toWord28": big -> word;
+            val toBig = _prim "WordU28_toWord32": word -> big;
+            val wordSize = 28
+         end
+      structure Word29 =
+         struct
+            open Word29
+            type big = Word32.word
+            val fromBigUnsafe = _prim "WordU32_toWord29": big -> word;
+            val toBig = _prim "WordU29_toWord32": word -> big;
+            val wordSize = 29
+         end
+      structure Word30 =
+         struct
+            open Word30
+            type big = Word32.word
+            val fromBigUnsafe = _prim "WordU32_toWord30": big -> word;
+            val toBig = _prim "WordU30_toWord32": word -> big;
+            val wordSize = 30
+         end
+      structure Word31 =
+         struct
+            open Word31
+            type big = Word32.word
+            val fromBigUnsafe = _prim "WordU32_toWord31": big -> word;
+            val toBig = _prim "WordU31_toWord32": word -> big;
+            val wordSize = 31
+         end
+      structure Word32 =
+         struct
+            open Word32
+               
+            val wordSize: int = 32
+
+            val + = _prim "Word32_add": word * word -> word;
+            val andb = _prim "Word32_andb": word * word -> word;
+            val ~>> = _prim "WordS32_rshift": word * word -> word;
+            val div = _prim "WordU32_quot": word * word -> word;
+            val fromInt = _prim "WordU32_toWord32": int -> word;
+            val fromLarge = _prim "WordU64_toWord32": LargeWord.word -> word;
+            val << = _prim "Word32_lshift": word * word -> word;
+            val op < = _prim "WordU32_lt": word * word -> bool;
+            val mod = _prim "WordU32_rem": word * word -> word;
+            val * = _prim "WordU32_mul": word * word -> word;
+            val ~ = _prim "Word32_neg": word -> word;
+            val notb = _prim "Word32_notb": word -> word;
+            val orb = _prim "Word32_orb": word * word -> word;
+            val rol = _prim "Word32_rol": word * word -> word;
+            val ror = _prim "Word32_ror": word * word -> word;
+            val >> = _prim "WordU32_rshift": word * word -> word;
+            val - = _prim "Word32_sub": word * word -> word;
+            val toInt = _prim "WordU32_toWord32": word -> int;
+            val toIntX = _prim "WordS32_toWord32": word -> int;
+            val toLarge = _prim "WordU32_toWord64": word -> LargeWord.word;
+            val toLargeX = _prim "WordS32_toWord64": word -> LargeWord.word;
+            val xorb = _prim "Word32_xorb": word * word -> word;
+         end
+      structure Word32 =
+         struct
+            open Word32
+            local
+               structure S = Comparisons (Word32)
+            in
+               open S
+            end
+         end
+      structure Word = Word32
+      structure Word64 =
+         struct
+            open Word64
+               
+            val wordSize: int = 64
+
+            val + = _prim "Word64_add": word * word -> word;
+            val andb = _prim "Word64_andb": word * word -> word;
+            val ~>> = _prim "WordS64_rshift": word * Word.word -> word;
+            val div = _prim "WordU64_quot": word * word -> word;
+            val fromInt = _prim "WordS32_toWord64": int -> word;
+            val fromLarge: LargeWord.word -> word = fn x => x
+            val << = _prim "Word64_lshift": word * Word.word -> word;
+            val op < = _prim "WordU64_lt": word * word -> bool;
+            val mod = _prim "WordU64_rem": word * word -> word;
+            val * = _prim "WordU64_mul": word * word -> word;
+            val ~ = _prim "Word64_neg": word -> word;
+            val notb = _prim "Word64_notb": word -> word;
+            val orb = _prim "Word64_orb": word * word -> word;
+            val >> = _prim "WordU64_rshift": word * Word.word -> word;
+            val - = _prim "Word64_sub": word * word -> word;
+            val toInt = _prim "WordU64_toWord32": word -> int;
+            val toIntX = _prim "WordU64_toWord32": word -> int;
+            val toLarge: word -> LargeWord.word = fn x => x
+            val toLargeX: word -> LargeWord.word = fn x => x
+            val xorb = _prim "Word64_xorb": word * word -> word;
+         end
+      structure Word64 =
+         struct
+            open Word64
+            local
+               structure S = Comparisons (Word64)
+            in
+               open S
+            end
+         end
+
+      structure Cygwin =
+         struct
+            val toFullWindowsPath =
+               _import "Cygwin_toFullWindowsPath": NullString.t -> CString.t;
+         end
+
+      structure FileDesc:>
+         sig
+            eqtype t
+
+            val fromWord: word -> t
+            val fromInt: int -> t
+            val toInt: t -> int
+            val toWord: t -> word
+         end =
+         struct
+            type t = int
+
+            val fromWord = Word32.toInt
+            fun fromInt i = i
+            fun toInt i = i
+            val toWord = Word32.fromInt
+         end
+
+      structure Windows =
+         struct
+            structure Process =
+               struct
+                  val create = 
+                     _import "Windows_Process_create"
+                     : (NullString.t * NullString.t * NullString.t
+                        * FileDesc.t * FileDesc.t * FileDesc.t) -> Pid.t;
+                  val terminate =
+                     _import "Windows_terminate": Pid.t * Signal.t -> int;
+               end
+         end
+
+      structure World =
+         struct
+            val getAmOriginal = _import "GC_getAmOriginal": GCState.t -> bool;
+            val setAmOriginal = _import "GC_setAmOriginal": GCState.t * bool -> unit;
+            val save = _prim "World_save": word (* filedes *) -> unit;
+         end
+   end
+
+structure Primitive =
+   struct
+      open Primitive
+
+      structure Int32 =
+         struct
+            open Int32
+               
+            local
+               fun make f (i: int, i': int): bool =
+                  f (Primitive.Word32.fromInt i, Primitive.Word32.fromInt i')
+            in
+               val geu = make Primitive.Word32.>=
+               val gtu = make Primitive.Word32.> 
+            end
+         end
+      structure Int = Int32
+   end
+
+structure NullString =
+   struct
+      open NullString
+
+      fun fromString s =
+         if #"\000" = let
+                         open Primitive
+                      in
+                         Vector.sub (s, Int.- (Vector.length s, 1))
+                      end
+            then NullString.fromString s
+         else raise Fail "NullString.fromString"
+
+      val empty = fromString "\000"
+   end
+structure NullString8 = NullString
+structure NullString8Array = struct type t = NullString8.t array end
+
+(* Quell unused warnings. *)
+local
+   val _ = #"a": Char16.t: Char16.char
+   val _ = #"a": Char32.t: Char32.char
+   val _ = "a": String16.t: String16.string
+   val _ = "a": String32.t: String32.string
+   open Primitive
+   open Char2
+   val _ = op <
+   val _ = chr
+   val _ = ord
+   open Char4
+   val _ = op <
+   val _ = chr
+   val _ = ord
+   open Int64
+   val _ = << 
+   val _ = >>
+   val _ = ~>>
+   val _ = andb
+in
+end
+
+(* Install an emergency exception handler. *)
+local
+   open Primitive
+   val _ =
+      TopLevel.setHandler 
+      (fn exn => 
+       (Stdio.print "unhandled exception: "
+        ; case exn of
+             Fail msg => (Stdio.print "Fail "
+                          ; Stdio.print msg)
+           | _ => Stdio.print (Exn.name exn)
+        ; Stdio.print "\n"
+        ; bug (NullString.fromString 
+               "unhandled exception in Basis Library\000")))
+in
+end

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library/real/pack-real.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library/real/pack-real.sml	2006-01-28 17:09:17 UTC (rev 4323)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/real/pack-real.sml	2006-01-28 17:54:57 UTC (rev 4324)
@@ -10,10 +10,10 @@
                         type real
                         val bytesPerElem: int
                         val isBigEndian: bool
-                        val subVec: word8 vector * int -> real
-                        val subVecRev: word8 vector * int -> real
-                        val update: word8 array * int * real -> unit
-                        val updateRev: word8 array * int * real -> unit
+                        val subVec: Word8.word vector * int -> real
+                        val subVecRev: Word8.word vector * int -> real
+                        val update: Word8.word array * int * real -> unit
+                        val updateRev: Word8.word array * int * real -> unit
                      end): PACK_REAL =
 struct
 

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library/system/date.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library/system/date.sml	2006-01-28 17:09:17 UTC (rev 4323)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/system/date.sml	2006-01-28 17:54:57 UTC (rev 4324)
@@ -9,7 +9,7 @@
 
 structure Date :> DATE =
   struct
-     structure Prim = Primitive.Date
+     structure Prim = PrimitiveFFI.Date
      structure Tm = Prim.Tm
         
      (* Patch to make Time look like it deals with Int.int
@@ -70,38 +70,38 @@
                  tm_year   : int}
 
     local
-       fun make (f: int ref -> unit) (n: int): tmoz =
-          (f (ref n)
-           ; {tm_hour = Tm.hour (),
-              tm_isdst = Tm.isdst (),
-              tm_mday = Tm.mday (),
-              tm_min = Tm.min (),
-              tm_mon = Tm.mon (),
-              tm_sec = Tm.sec (),
-              tm_wday = Tm.wday (),
-              tm_yday = Tm.yday (),
-              tm_year = Tm.year ()})
+       fun make (f: int ref -> int) (n: int): tmoz =
+          (ignore (f (ref n))
+           ; {tm_hour = Tm.getHour (),
+              tm_isdst = Tm.getIsDst (),
+              tm_mday = Tm.getMDay (),
+              tm_min = Tm.getMin (),
+              tm_mon = Tm.getMon (),
+              tm_sec = Tm.getSec (),
+              tm_wday = Tm.getWDay (),
+              tm_yday = Tm.getYDay (),
+              tm_year = Tm.getYear ()})
     in
        val getlocaltime_ = make Prim.localTime
-       val getunivtime_ = make Prim.gmTime
+       val getgmtime_ = make Prim.gmTime
     end
 
     fun setTmBuf {tm_hour, tm_isdst, tm_mday, tm_min, tm_mon, tm_sec, tm_wday,
                  tm_yday, tm_year} =
        (Tm.setHour tm_hour
-        ; Tm.setIsdst tm_isdst
-        ; Tm.setMday tm_mday
+        ; Tm.setIsDst tm_isdst
+        ; Tm.setMDay tm_mday
         ; Tm.setMin tm_min
         ; Tm.setMon tm_mon
         ; Tm.setSec tm_sec
-        ; Tm.setWday tm_wday
-        ; Tm.setYday tm_yday
+        ; Tm.setWDay tm_wday
+        ; Tm.setYDay tm_yday
         ; Tm.setYear tm_year)
         
     fun mktime_ (t: tmoz): int = (setTmBuf t; Prim.mkTime ())
 
     (* The offset to add to local time to get UTC: positive West of UTC *)
-    val localoffset: int = Prim.localOffset ()
+    val localoffset: int = Real.round (Prim.localOffset ())
 
     val toweekday: int -> weekday =
        fn 0 => Sun | 1 => Mon | 2 => Tue | 3 => Wed
@@ -282,7 +282,7 @@
         tmozToDate (getlocaltime_ (Time.toSeconds t)) NONE
 
     fun fromTimeUniv t = 
-        tmozToDate (getunivtime_ (Time.toSeconds t)) (SOME 0)
+        tmozToDate (getgmtime_ (Time.toSeconds t)) (SOME 0)
 
     (* The following implements conversion from a local date to 
      * a Time.time.  It IGNORES wday and yday.
@@ -322,8 +322,9 @@
                 let
                    val len =
                       Prim.strfTime
-                      (buf, bufLen,
+                      (buf, Word.fromInt bufLen,
                        NullString.fromString (concat ["%", str fmtChar, "\000"]))
+                   val len = Word.toInt len
                 in if len = 0
                       then raise Fail "Date.fmt"
                    else ArraySlice.vector (ArraySlice.slice (buf, 0, SOME len))

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/basis/MLton/Rusage/rusage.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/basis/MLton/Rusage/rusage.c	2006-01-28 17:09:17 UTC (rev 4323)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/MLton/Rusage/rusage.c	2006-01-28 17:54:57 UTC (rev 4324)
@@ -1,5 +1,7 @@
 #include "platform.h"
 
+extern struct GC_state gcState;
+
 static struct rusage self;
 static struct rusage children;
 static struct rusage gc;
@@ -52,8 +54,8 @@
   return gc.ru_stime.tv_usec;
 }
 
-void MLton_Rusage_getrusage (GC_state s) {
-  gc = *(GC_getRusageGCAddr (s));
+void MLton_Rusage_getrusage (void) {
+  gc = *(GC_getRusageGCAddr (&gcState));
   getrusage (RUSAGE_SELF, &self);
   getrusage (RUSAGE_CHILDREN, &children);
 }

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gen/basis-ffi.def
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gen/basis-ffi.def	2006-01-28 17:09:17 UTC (rev 4323)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gen/basis-ffi.def	2006-01-28 17:54:57 UTC (rev 4324)
@@ -58,7 +58,7 @@
 MLton.Rusage.gc_stime_usec = _import : unit -> C.SUSeconds.t
 MLton.Rusage.gc_utime_sec = _import : unit -> C.Time.t
 MLton.Rusage.gc_utime_usec = _import : unit -> C.SUSeconds.t
-MLton.Rusage.getrusage = _import : GCState.t -> unit
+MLton.Rusage.getrusage = _import : unit -> unit
 MLton.Rusage.self_stime_sec = _import : unit -> C.Time.t
 MLton.Rusage.self_stime_usec = _import : unit -> C.SUSeconds.t
 MLton.Rusage.self_utime_sec = _import : unit -> C.Time.t