[MLton-commit] r4327

Matthew Fluet MLton@mlton.org
Sat, 28 Jan 2006 13:30:50 -0800


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

U   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/libs/basis-extra/basis-extra.mlb
U   mlton/branches/on-20050822-x86_64-branch/basis-library/mlton/itimer.sml
U   mlton/branches/on-20050822-x86_64-branch/basis-library/mlton/signal.sml
U   mlton/branches/on-20050822-x86_64-branch/basis-library/mlton/world.sml
U   mlton/branches/on-20050822-x86_64-branch/basis-library/net/inet-sock.sml
U   mlton/branches/on-20050822-x86_64-branch/basis-library/net/net-host-db.sml
U   mlton/branches/on-20050822-x86_64-branch/basis-library/net/net-prot-db.sml
U   mlton/branches/on-20050822-x86_64-branch/basis-library/net/net-serv-db.sml
U   mlton/branches/on-20050822-x86_64-branch/basis-library/net/net.sig
U   mlton/branches/on-20050822-x86_64-branch/basis-library/net/net.sml
U   mlton/branches/on-20050822-x86_64-branch/basis-library/posix/error.sml
U   mlton/branches/on-20050822-x86_64-branch/basis-library/posix/signal.sig
U   mlton/branches/on-20050822-x86_64-branch/basis-library/posix/signal.sml
U   mlton/branches/on-20050822-x86_64-branch/basis-library/posix/stub-mingw.sml
U   mlton/branches/on-20050822-x86_64-branch/basis-library/primitive/posix-primitive.sml
U   mlton/branches/on-20050822-x86_64-branch/basis-library/primitive/primitive.sml
U   mlton/branches/on-20050822-x86_64-branch/basis-library/system/command-line.sml
U   mlton/branches/on-20050822-x86_64-branch/basis-library/system/io.sml
U   mlton/branches/on-20050822-x86_64-branch/runtime/basis/Net/NetHostDB-consts.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/basis/Net/NetHostDB.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/cenv.h
U   mlton/branches/on-20050822-x86_64-branch/runtime/gen/basis-ffi.def
U   mlton/branches/on-20050822-x86_64-branch/runtime/gen/gen-types.c

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

Modified: 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 19:13:54 UTC (rev 4326)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/config/c/amd64-linux/c-types.sml	2006-01-28 21:30:43 UTC (rev 4327)
@@ -9,27 +9,27 @@
 
 
 (* 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 Char = struct open Int8 type t = int end
+structure SChar = struct open Int8 type t = int end
+structure UChar = struct open Word8 type t = word end
+structure Short = struct open Int16 type t = int end
+structure SShort = struct open Int16 type t = int end
+structure UShort = struct open Word16 type t = word end
+structure Int = struct open Int32 type t = int end
+structure SInt = struct open Int32 type t = int end
+structure UInt = struct open Word32 type t = word end
+structure Long = struct open Int32 type t = int end
+structure SLong = struct open Int32 type t = int end
+structure ULong = struct open Word32 type t = word end
+structure LongLong = struct open Int64 type t = int end
+structure SLongLong = struct open Int64 type t = int end
+structure ULongLong = struct open Word64 type t = word end
+structure Float = struct open Real32 type t = real end
+structure Double = struct open Real64 type t = real end
+structure Size = struct open Word32 type t = word end
 
-structure String = Word32
-structure StringArray = Word32
+structure String = Pointer
+structure StringArray = Pointer
 
 (* Generic integers *)
 structure Fd = Int
@@ -38,40 +38,40 @@
 structure Sock = Int
 
 (* from <dirent.h> *)
-structure DirP = Word32
+structure DirP = struct open Word32 type t = word end
 
 (* from <poll.h> *)
-structure NFds = Word32
+structure NFds = struct open Word32 type t = word end
 
 (* from <resource.h> *)
-structure RLim = Word64
+structure RLim = struct open Word64 type t = word end
 
 (* 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
+structure Clock = struct open Int32 type t = int end
+structure Dev = struct open Word64 type t = word end
+structure GId = struct open Word32 type t = word end
+structure Id = struct open Word32 type t = word end
+structure INo = struct open Word64 type t = word end
+structure Mode = struct open Word32 type t = word end
+structure NLink = struct open Word32 type t = word end
+structure Off = struct open Int64 type t = int end
+structure PId = struct open Int32 type t = int end
+structure SSize = struct open Int32 type t = int end
+structure SUSeconds = struct open Int32 type t = int end
+structure Time = struct open Int32 type t = int end
+structure UId = struct open Word32 type t = word end
+structure USeconds = struct open Word32 type t = word end
 
 (* from <sys/socket.h> *)
-structure Socklen = Word32
+structure Socklen = struct open Word32 type t = word end
 
 (* from <termios.h> *)
-structure CC = Word8
-structure Speed = Word32
-structure TCFlag = Word32
+structure CC = struct open Word8 type t = word end
+structure Speed = struct open Word32 type t = word end
+structure TCFlag = struct open Word32 type t = word end
 
 (* from "gmp.h" *)
-structure MPLimb = Word32
+structure MPLimb = struct open Word32 type t = word end
 
 
 structure Errno = struct type 'a t = 'a end

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 19:13:54 UTC (rev 4326)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/libs/basis-extra/basis-extra.mlb	2006-01-28 21:30:43 UTC (rev 4327)
@@ -87,6 +87,9 @@
       ../../integer/patch.sml
       ../../integer/embed-int.sml
       ../../integer/embed-word.sml
+      ann "forceUsed" in
+         ../../config/c/$(TARGET_ARCH)-$(TARGET_OS)/c-types.sml
+      end
 
       ../../top-level/arithmetic.sml
 

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library/mlton/itimer.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library/mlton/itimer.sml	2006-01-28 19:13:54 UTC (rev 4326)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/mlton/itimer.sml	2006-01-28 21:30:43 UTC (rev 4327)
@@ -13,9 +13,9 @@
       datatype t = Prof | Real | Virtual
 
       val signal =
-         fn Prof => PosixPrimitive.Signal.prof
-          | Real => PosixPrimitive.Signal.alrm
-          | Virtual => PosixPrimitive.Signal.vtalrm
+         fn Prof => PosixSignal.prof
+          | Real => PosixSignal.alrm
+          | Virtual => PosixSignal.vtalrm
 
       val toInt =
          fn Prof => Prim.PROF

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library/mlton/signal.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library/mlton/signal.sml	2006-01-28 19:13:54 UTC (rev 4326)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/mlton/signal.sml	2006-01-28 21:30:43 UTC (rev 4327)
@@ -10,18 +10,15 @@
 struct
 
 open Posix.Signal
-structure Prim = PosixPrimitive.Signal
+structure Prim = PrimitiveFFI.Posix.Signal
 structure Error = PosixError
 structure SysCall = Error.SysCall
 val restart = SysCall.restartFlag
 
 type t = signal
 
-val prof = Prim.prof
-val vtalrm = Prim.vtalrm
+type how = C.Int.t
 
-type how = Prim.how
-
 (* val toString = SysWord.toString o toWord *)
    
 fun raiseInval () =
@@ -33,7 +30,7 @@
 
 val validSignals = 
    Array.tabulate 
-   (Prim.numSignals, fn i => 
+   (Prim.NSIG, fn i => 
     Prim.sigismember(fromInt i) <> ~1)
 
 structure Mask =
@@ -73,10 +70,10 @@
          fun make (how: how) (m: t) =
             (write m; SysCall.simpleRestart (fn () => Prim.sigprocmask how))
       in
-         val block = make Prim.block
-         val unblock = make Prim.unblock
-         val setBlocked = make Prim.setmask
-         fun getBlocked () = (make Prim.block none; read ())
+         val block = make Prim.SIG_BLOCK
+         val unblock = make Prim.SIG_UNBLOCK
+         val setBlocked = make Prim.SIG_SETMASK
+         fun getBlocked () = (make Prim.SIG_BLOCK none; read ())
       end
 
       local
@@ -115,7 +112,7 @@
 
 val (getHandler, setHandler, handlers) =
    let
-      val handlers = Array.tabulate (Prim.numSignals, initHandler o fromInt)
+      val handlers = Array.tabulate (Prim.NSIG, initHandler o fromInt)
       val _ =
          Cleaner.addNew
          (Cleaner.atLoadWorld, fn () =>
@@ -179,7 +176,7 @@
                    val () = Mask.block (handled ())
                    val fs = 
                       case !gcHandler of
-                         Handler f => if Prim.isGCPending () then [f] else []
+                         Handler f => if Prim.isPendingGC () then [f] else []
                        | _ => []
                    val fs =
                       Array.foldri
@@ -220,7 +217,7 @@
 
 fun suspend m =
    (Mask.write m
-    ; Prim.suspend ()
+    ; Prim.sigsuspend ()
     ; MLtonThread.switchToSignalHandler ())
 
 fun handleGC f =

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library/mlton/world.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library/mlton/world.sml	2006-01-28 19:13:54 UTC (rev 4326)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/mlton/world.sml	2006-01-28 21:30:43 UTC (rev 4327)
@@ -39,7 +39,7 @@
                                          file, " due to ",
                                          General.exnMessage e])
                end
-            val _ = Prim.save (Posix.FileSys.fdToWord fd)
+            val _ = Prim.save fd
          in
             if Prim.getAmOriginal gcState
                then (Posix.IO.close fd; Original)

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library/net/inet-sock.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library/net/inet-sock.sml	2006-01-28 19:13:54 UTC (rev 4326)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/net/inet-sock.sml	2006-01-28 21:30:43 UTC (rev 4327)
@@ -24,7 +24,7 @@
             let
                val (sa, salen, finish) = Socket.new_sock_addr ()
                val _ = Prim.toAddr (NetHostDB.inAddrToWord8Vector in_addr,
-                                    Net.htons port, sa, salen)
+                                    Net.htonl port, sa, salen)
             in
                finish ()
             end
@@ -34,7 +34,7 @@
       fun fromAddr sa =
         let
           val _ = Prim.fromAddr (Word8Vector.toPoly (Socket.unpackSockAddr sa))
-          val port = Net.ntohs (Prim.getPort ())
+          val port = Net.ntohl (Prim.getPort ())
           val (ia, finish) = NetHostDB.new_in_addr ()
           val _ = Prim.getInAddr (NetHostDB.preInAddrToWord8Array ia)
         in

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library/net/net-host-db.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library/net/net-host-db.sml	2006-01-28 19:13:54 UTC (rev 4326)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/net/net-host-db.sml	2006-01-28 21:30:43 UTC (rev 4327)
@@ -7,11 +7,11 @@
 
 structure NetHostDB:> NET_HOST_DB_EXTRA =
    struct
-      structure Prim = Primitive.NetHostDB
+      structure Prim = PrimitiveFFI.NetHostDB
 
       (* network byte order (MSB) *)
-      type pre_in_addr = Prim.pre_in_addr
-      type in_addr = Prim.in_addr
+      type pre_in_addr = Word8.word array
+      type in_addr = Word8.word vector
 
       val preInAddrToWord8Array = fn a => a
       val inAddrToWord8Vector = fn v => v
@@ -19,7 +19,8 @@
       structure PW = PackWord32Big
       fun new_in_addr () =
         let
-          val ia: pre_in_addr = Array.array (Prim.inAddrLen, 0wx0: Word8.word)
+          val inAddrLen = Word32.toIntX Prim.inAddrSize
+          val ia: pre_in_addr = Array.array (inAddrLen, 0wx0: Word8.word)
           fun finish () = Array.vector ia
         in
           (ia, finish)
@@ -34,7 +35,7 @@
           finish ()
         end
       fun any () = wordToInAddr (Word.fromInt Prim.INADDR_ANY)
-      type addr_family = Prim.addr_family
+      type addr_family = C.Int.t
 
       val intToAddrFamily = fn z => z
       val addrFamilyToInt = fn z => z
@@ -58,27 +59,27 @@
         fun get (b: bool): entry option =
           if b
             then let
-                   val name = COld.CS.toString (Prim.entryName ())
-                   val numAliases = Prim.entryNumAliases ()
+                   val name = COld.CS.toString (Prim.getEntryName ())
+                   val numAliases = Prim.getEntryAliasesNum ()
                    fun fill (n, aliases) =
                      if n < numAliases
                        then let
                               val alias =
-                                COld.CS.toString (Prim.entryAliasesN n)
+                                COld.CS.toString (Prim.getEntryAliasesN n)
                             in
                               fill (n + 1, alias::aliases)
                             end
                        else List.rev aliases
                    val aliases = fill (0, [])
-                   val addrType = Prim.entryAddrType ()
-                   val length = Prim.entryLength ()
-                   val numAddrs = Prim.entryNumAddrs ()
+                   val addrType = Prim.getEntryAddrType ()
+                   val length = Prim.getEntryLength ()
+                   val numAddrs = Prim.getEntryAddrsNum ()
                    fun fill (n, addrs) =
                      if n < numAddrs
                        then let
                               val addr = Word8Array.array (length, 0wx0)
                               val _ =
-                                 Prim.entryAddrsN (n, Word8Array.toPoly addr)
+                                 Prim.getEntryAddrsN (n, Word8Array.toPoly addr)
                               val addr =
                                  Word8Vector.toPoly (Word8Array.vector addr)
                             in
@@ -95,7 +96,7 @@
             else NONE
       in
         fun getByAddr in_addr = 
-           get (Prim.getByAddress (in_addr, Vector.length in_addr))
+           get (Prim.getByAddress (in_addr, C.Socklen.fromInt (Vector.length in_addr)))
         fun getByName name = 
            get (Prim.getByName (NullString.nullTerm name))
       end
@@ -106,7 +107,7 @@
           val buf = CharArray.array (n, #"\000")
           val () =
              Posix.Error.SysCall.simple
-             (fn () => Prim.getHostName (CharArray.toPoly buf, n))
+             (fn () => Prim.getHostName (CharArray.toPoly buf, C.Size.fromInt n))
         in
           case CharArray.findi (fn (_, c) => c = #"\000") buf of
              NONE => CharArray.vector buf

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library/net/net-prot-db.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library/net/net-prot-db.sml	2006-01-28 19:13:54 UTC (rev 4326)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/net/net-prot-db.sml	2006-01-28 21:30:43 UTC (rev 4327)
@@ -7,7 +7,7 @@
 
 structure NetProtDB: NET_PROT_DB =
    struct
-      structure Prim = Primitive.NetProtDB
+      structure Prim = PrimitiveFFI.NetProtDB
 
       datatype entry = T of {name: string,
                              aliases: string list,
@@ -25,19 +25,19 @@
         fun get (b: bool): entry option =
           if b
             then let
-                   val name = COld.CS.toString (Prim.entryName ())
-                   val numAliases = Prim.entryNumAliases ()
+                   val name = COld.CS.toString (Prim.getEntryName ())
+                   val numAliases = Prim.getEntryAliasesNum ()
                    fun fill (n, aliases) =
                      if n < numAliases
                        then let
                               val alias =
-                                COld.CS.toString (Prim.entryAliasesN n)
+                                COld.CS.toString (Prim.getEntryAliasesN n)
                             in
                               fill (n + 1, alias::aliases)
                             end
                        else List.rev aliases
                    val aliases = fill (0, [])
-                   val protocol = Prim.entryProtocol ()
+                   val protocol = Prim.getEntryProto ()
                  in
                    SOME (T {name = name,
                             aliases = aliases,

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library/net/net-serv-db.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library/net/net-serv-db.sml	2006-01-28 19:13:54 UTC (rev 4326)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/net/net-serv-db.sml	2006-01-28 21:30:43 UTC (rev 4327)
@@ -7,7 +7,7 @@
 
 structure NetServDB: NET_SERV_DB =
    struct
-      structure Prim = Primitive.NetServDB
+      structure Prim = PrimitiveFFI.NetServDB
 
       datatype entry = T of {name: string,
                              aliases: string list,
@@ -27,20 +27,20 @@
         fun get (b: bool): entry option =
           if b
             then let
-                   val name = COld.CS.toString (Prim.entryName ())
-                   val numAliases = Prim.entryNumAliases ()
+                   val name = COld.CS.toString (Prim.getEntryName ())
+                   val numAliases = Prim.getEntryAliasesNum ()
                    fun fill (n, aliases) =
                      if n < numAliases
                        then let
                               val alias =
-                                COld.CS.toString (Prim.entryAliasesN n)
+                                COld.CS.toString (Prim.getEntryAliasesN n)
                             in
                               fill (n + 1, alias::aliases)
                             end
                        else List.rev aliases
                    val aliases = fill (0, [])
-                   val port = Net.ntohs (Prim.entryPort ())
-                   val protocol = COld.CS.toString (Prim.entryProtocol ())
+                   val port = Net.ntohl (Prim.getEntryPort ())
+                   val protocol = COld.CS.toString (Prim.getEntryProto ())
                  in
                    SOME (T {name = name,
                             aliases = aliases,
@@ -56,7 +56,7 @@
           | NONE => get (Prim.getByNameNull (NullString.nullTerm name))
         fun getByPort (port, proto) = 
           let
-            val port = Net.htons port
+            val port = Net.htonl port
           in
             case proto of
                NONE => get (Prim.getByPortNull port)

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library/net/net.sig
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library/net/net.sig	2006-01-28 19:13:54 UTC (rev 4326)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/net/net.sig	2006-01-28 21:30:43 UTC (rev 4327)
@@ -1,7 +1,7 @@
 signature NET =
    sig
-(*     val htonl: int -> int *)
-(*     val ntohl: int -> int *)
-     val htons: int -> int
-     val ntohs: int -> int
+      val htonl: Int32.int -> Int32.int
+      val ntohl: Int32.int -> Int32.int
+      val htons: Int16.int -> Int16.int
+      val ntohs: Int16.int -> Int16.int
    end

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library/net/net.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library/net/net.sml	2006-01-28 19:13:54 UTC (rev 4326)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/net/net.sml	2006-01-28 21:30:43 UTC (rev 4327)
@@ -7,10 +7,10 @@
 
 structure Net : NET =
    struct
-      structure Prim = Primitive.Net
+      structure Prim = PrimitiveFFI.Net
 
-(*      val htonl = Prim.htonl *)
-(*      val ntohl = Prim.ntohl *)
-      val htons = Prim.htons
-      val ntohs = Prim.ntohs
+      val htonl = Primitive.Word32.toInt32 o Prim.htonl o Primitive.Word32.fromInt32
+      val ntohl = Primitive.Word32.toInt32 o Prim.ntohl o Primitive.Word32.fromInt32
+      val htons = Primitive.Word16.toInt16 o Prim.htons o Primitive.Word16.fromInt16
+      val ntohs = Primitive.Word16.toInt16 o Prim.ntohs o Primitive.Word16.fromInt16
    end

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library/posix/error.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library/posix/error.sml	2006-01-28 19:13:54 UTC (rev 4326)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/posix/error.sml	2006-01-28 21:30:43 UTC (rev 4327)
@@ -8,9 +8,174 @@
 
 structure PosixError: POSIX_ERROR_EXTRA =
    struct
-      structure Prim = PosixPrimitive.Error
+      structure Prim = PrimitiveFFI.Posix.Error
       open Prim
-         
+
+      type syserror = C.Int.t
+ 
+      val acces = EACCES
+      val addrinuse = EADDRINUSE
+      val addrnotavail = EADDRNOTAVAIL
+      val afnosupport = EAFNOSUPPORT
+      val again = EAGAIN
+      val already = EALREADY
+      val badf = EBADF
+      val badmsg = EBADMSG
+      val busy = EBUSY
+      val canceled = ECANCELED
+      val child = ECHILD
+      val connaborted = ECONNABORTED
+      val connrefused = ECONNREFUSED
+      val connreset = ECONNRESET
+      val deadlk = EDEADLK
+      val destaddrreq = EDESTADDRREQ
+      val dom = EDOM
+      val dquot = EDQUOT
+      val exist = EEXIST
+      val fault = EFAULT
+      val fbig = EFBIG
+      val hostunreach = EHOSTUNREACH
+      val idrm = EIDRM
+      val ilseq = EILSEQ
+      val inprogress = EINPROGRESS
+      val intr = EINTR
+      val inval = EINVAL
+      val io = EIO
+      val isconn = EISCONN
+      val isdir = EISDIR
+      val loop = ELOOP
+      val mfile = EMFILE
+      val mlink = EMLINK
+      val msgsize = EMSGSIZE
+      val multihop = EMULTIHOP
+      val nametoolong = ENAMETOOLONG
+      val netdown = ENETDOWN
+      val netreset = ENETRESET
+      val netunreach = ENETUNREACH
+      val nfile = ENFILE
+      val nobufs = ENOBUFS
+      val nodata = ENODATA
+      val nodev = ENODEV
+      val noent = ENOENT
+      val noexec = ENOEXEC
+      val nolck = ENOLCK
+      val nolink = ENOLINK
+      val nomem = ENOMEM
+      val nomsg = ENOMSG
+      val noprotoopt = ENOPROTOOPT
+      val nospc = ENOSPC
+      val nosr = ENOSR
+      val nostr = ENOSTR
+      val nosys = ENOSYS
+      val notconn = ENOTCONN
+      val notdir = ENOTDIR
+      val notempty = ENOTEMPTY
+      val notsock = ENOTSOCK
+      val notsup = ENOTSUP
+      val notty = ENOTTY
+      val nxio = ENXIO
+      val opnotsupp = EOPNOTSUPP
+      val overflow = EOVERFLOW
+      val perm = EPERM
+      val pipe = EPIPE
+      val proto = EPROTO
+      val protonosupport = EPROTONOSUPPORT
+      val prototype = EPROTOTYPE
+      val range = ERANGE
+      val rofs = EROFS
+      val spipe = ESPIPE
+      val srch = ESRCH
+      val stale = ESTALE
+      val time = ETIME
+      val timedout = ETIMEDOUT
+      val toobig = E2BIG
+      val txtbsy = ETXTBSY
+      val wouldblock = EWOULDBLOCK
+      val xdev = EXDEV
+
+      val errorNames =
+         [
+          (acces,"acces"),
+          (addrinuse,"addrinuse"),
+          (addrnotavail,"addrnotavail"),
+          (afnosupport,"afnosupport"),
+          (again,"again"),
+          (already,"already"),
+          (badf,"badf"),
+          (badmsg,"badmsg"),
+          (busy,"busy"),
+          (canceled,"canceled"),
+          (child,"child"),
+          (connaborted,"connaborted"),
+          (connrefused,"connrefused"),
+          (connreset,"connreset"),
+          (deadlk,"deadlk"),
+          (destaddrreq,"destaddrreq"),
+          (dom,"dom"),
+          (dquot,"dquot"),
+          (exist,"exist"),
+          (fault,"fault"),
+          (fbig,"fbig"),
+          (hostunreach,"hostunreach"),
+          (idrm,"idrm"),
+          (ilseq,"ilseq"),
+          (inprogress,"inprogress"),
+          (intr,"intr"),
+          (inval,"inval"),
+          (io,"io"),
+          (isconn,"isconn"),
+          (isdir,"isdir"),
+          (loop,"loop"),
+          (mfile,"mfile"),
+          (mlink,"mlink"),
+          (msgsize,"msgsize"),
+          (multihop,"multihop"),
+          (nametoolong,"nametoolong"),
+          (netdown,"netdown"),
+          (netreset,"netreset"),
+          (netunreach,"netunreach"),
+          (nfile,"nfile"),
+          (nobufs,"nobufs"),
+          (nodata,"nodata"),
+          (nodev,"nodev"),
+          (noent,"noent"),
+          (noexec,"noexec"),
+          (nolck,"nolck"),
+          (nolink,"nolink"),
+          (nomem,"nomem"),
+          (nomsg,"nomsg"),
+          (noprotoopt,"noprotoopt"),
+          (nospc,"nospc"),
+          (nosr,"nosr"),
+          (nostr,"nostr"),
+          (nosys,"nosys"),
+          (notconn,"notconn"),
+          (notdir,"notdir"),
+          (notempty,"notempty"),
+          (notsock,"notsock"),
+          (notsup,"notsup"),
+          (notty,"notty"),
+          (nxio,"nxio"),
+          (opnotsupp,"opnotsupp"),
+          (overflow,"overflow"),
+          (perm,"perm"),
+          (pipe,"pipe"),
+          (proto,"proto"),
+          (protonosupport,"protonosupport"),
+          (prototype,"prototype"),
+          (range,"range"),
+          (rofs,"rofs"),
+          (spipe,"spipe"),
+          (srch,"srch"),
+          (stale,"stale"),
+          (time,"time"),
+          (timedout,"timedout"),
+          (toobig,"toobig"),
+          (txtbsy,"txtbsy"),
+          (wouldblock,"wouldblock"),
+          (xdev,"xdev")
+         ]
+
       exception SysErr of string * syserror option
 
       val toWord = SysWord.fromInt
@@ -41,7 +206,7 @@
 
       fun errorMsg (n: int) =
          let
-            val cs = strerror n
+            val cs = strError n
          in
             if cs = Primitive.Pointer.null
                then "Unknown error"

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library/posix/signal.sig
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library/posix/signal.sig	2006-01-28 19:13:54 UTC (rev 4326)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/posix/signal.sig	2006-01-28 21:30:43 UTC (rev 4327)
@@ -31,6 +31,9 @@
    sig
       include POSIX_SIGNAL
 
+      val prof: signal
+      val vtalrm: signal
+
       val fromInt: int -> signal
       val toInt: signal -> int
    end

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library/posix/signal.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library/posix/signal.sml	2006-01-28 19:13:54 UTC (rev 4326)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/posix/signal.sml	2006-01-28 21:30:43 UTC (rev 4327)
@@ -8,10 +8,42 @@
 
 structure PosixSignal: POSIX_SIGNAL_EXTRA =
    struct
-      open PosixPrimitive.Signal
+      open PrimitiveFFI.Posix.Signal
 
-      type signal = t
+      type signal = C.Int.t
+         
+      val abrt = SIGABRT
+      val alrm = SIGALRM
+      val bus = SIGBUS
+      val chld = SIGCHLD
+      val cont = SIGCONT
+      val fpe = SIGFPE
+      val hup = SIGHUP
+      val ill = SIGILL
+      val int = SIGINT
+      val kill = SIGKILL
+      val pipe = SIGPIPE
+      val poll = SIGPOLL
+      val prof = SIGPROF
+      val quit = SIGQUIT
+      val segv = SIGSEGV
+      val stop = SIGSTOP
+      val sys = SIGSYS
+      val term = SIGTERM
+      val trap = SIGTRAP
+      val tstp = SIGTSTP
+      val ttin = SIGTTIN
+      val ttou = SIGTTOU
+      val urg = SIGURG
+      val usr1 = SIGUSR1
+      val usr2 = SIGUSR2
+      val vtalrm = SIGVTALRM
+      val xcpu = SIGXCPU
+      val xfsz = SIGXFSZ
 
+      val toInt = C.Int.toInt
+      val fromInt = C.Int.fromInt
+
+      val toWord = SysWord.fromInt o toInt
       val fromWord = fromInt o SysWord.toInt
-      val toWord = SysWord.fromInt o toInt
    end

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library/posix/stub-mingw.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library/posix/stub-mingw.sml	2006-01-28 19:13:54 UTC (rev 4326)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/posix/stub-mingw.sml	2006-01-28 21:30:43 UTC (rev 4327)
@@ -110,18 +110,6 @@
       struct
          open Primitive
 
-         structure OS =
-            struct
-               open OS
-
-               structure IO =
-                  struct
-                     open IO
-
-                     val poll = stub ("poll", poll)
-                  end
-            end
-
          structure Socket =
             struct
                open Socket
@@ -150,5 +138,17 @@
                      val set = stub ("set", set)
                   end
             end
+
+         structure OS =
+            struct
+               open OS
+
+               structure IO =
+                  struct
+                     open IO
+
+                     val poll = stub ("poll", poll)
+                  end
+            end
       end
 end

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library/primitive/posix-primitive.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library/primitive/posix-primitive.sml	2006-01-28 19:13:54 UTC (rev 4326)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/primitive/posix-primitive.sml	2006-01-28 21:30:43 UTC (rev 4327)
@@ -22,153 +22,9 @@
       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 =

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library/primitive/primitive.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library/primitive/primitive.sml	2006-01-28 19:13:54 UTC (rev 4326)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/primitive/primitive.sml	2006-01-28 21:30:43 UTC (rev 4327)
@@ -52,7 +52,7 @@
       type 'a t = (unit -> 'a) * ('a -> unit)
    end
 
-structure Pid :> sig
+structure Pid : sig
                     eqtype t
 
                     val fromInt: int -> t
@@ -884,72 +884,13 @@
                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
@@ -1190,23 +1131,21 @@
             val assign = _prim "Ref_assign": 'a ref * 'a -> unit;
          end
 
-      structure Signal:>
+      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:>
+      structure Socket:
          sig
             type sock
 
@@ -1235,7 +1174,7 @@
                   val INET6 = _const "Socket_AF_INET6": addr_family;
                   val UNSPEC = _const "Socket_AF_UNSPEC": addr_family;
                end
-            structure SOCK:>
+            structure SOCK:
                sig
                   eqtype sock_type
 
@@ -1380,7 +1319,7 @@
                end
          end
 
-      structure Status:>
+      structure Status:
          sig
             eqtype t
 
@@ -1665,6 +1604,9 @@
             val toLarge = _prim "WordU16_toWord64": word -> LargeWord.word;
             val toLargeX = _prim "WordS16_toWord64": word -> LargeWord.word;
             val xorb = _prim "Word16_xorb": word * word -> word;
+
+            val toInt16 = _prim "WordU16_toWord16": word -> Int16.int;
+            val fromInt16 = _prim "WordU16_toWord16": Int16.int -> word;
          end
       structure Word16 =
          struct
@@ -1823,6 +1765,9 @@
             val toLarge = _prim "WordU32_toWord64": word -> LargeWord.word;
             val toLargeX = _prim "WordS32_toWord64": word -> LargeWord.word;
             val xorb = _prim "Word32_xorb": word * word -> word;
+
+            val toInt32 = _prim "WordU32_toWord32": word -> Int32.int;
+            val fromInt32 = _prim "WordU32_toWord32": Int32.int -> word;
          end
       structure Word32 =
          struct
@@ -1877,7 +1822,7 @@
                _import "Cygwin_toFullWindowsPath": NullString.t -> CString.t;
          end
 
-      structure FileDesc:>
+      structure FileDesc:
          sig
             eqtype t
 
@@ -1912,7 +1857,7 @@
          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;
+            val save = _prim "World_save": FileDesc.t -> unit;
          end
    end
 

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library/system/command-line.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library/system/command-line.sml	2006-01-28 19:13:54 UTC (rev 4326)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/system/command-line.sml	2006-01-28 21:30:43 UTC (rev 4327)
@@ -11,10 +11,9 @@
       structure Prim = PrimitiveFFI.CommandLine
          
       fun name () = 
-         COld.CS.toString 
-         (Primitive.Pointer.fromWord (Prim.commandNameGet ()))
+         COld.CS.toString (Prim.commandNameGet ())
 
       fun arguments () =
          (Array.toList o COld.CSS.toArrayOfLength) 
-         (Primitive.Pointer.fromWord (Prim.argvGet ()), Prim.argcGet ())
+         (Prim.argvGet (), Prim.argcGet ())
    end

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library/system/io.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library/system/io.sml	2006-01-28 19:13:54 UTC (rev 4326)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/system/io.sml	2006-01-28 21:30:43 UTC (rev 4327)
@@ -94,24 +94,28 @@
 
   (* polling function *)
     local
-      structure Prim = Primitive.OS.IO
+      structure Prim = PrimitiveFFI.OS.IO
       fun join (false, _, w) = w
-        | join (true, b, w) = Word.orb(w, b)
-      fun test (w, b) = (Word.andb(w, b) <> 0w0)
-      val rdBit : Word.word = Primitive.OS.IO.POLLIN
-      and wrBit : Word.word = Primitive.OS.IO.POLLOUT
-      and priBit : Word.word = Primitive.OS.IO.POLLPRI
+        | join (true, b, w) = Word16.orb(w, b)
+      fun test (w, b) = (Word16.andb(w, b) <> 0w0)
+      val rdBit : Word16.word = Primitive.Word16.fromInt16 PrimitiveFFI.OS.IO.POLLIN
+      and wrBit : Word16.word = Primitive.Word16.fromInt16 PrimitiveFFI.OS.IO.POLLOUT
+      and priBit : Word16.word = Primitive.Word16.fromInt16 PrimitiveFFI.OS.IO.POLLPRI
       fun fromPollDesc (PollDesc (iod, {rd, wr, pri})) =
             ( toInt iod,
+              Primitive.Word16.toInt16 (
               join (rd, rdBit, 
               join (wr, wrBit, 
-              join (pri, priBit, 0w0)))
+              join (pri, priBit, 0w0))))
             )
-      fun toPollInfo (fd, w) = PollInfo (fromInt fd, {
+      fun toPollInfo (fd, i) = 
+         let val w = Primitive.Word16.fromInt16 i
+         in PollInfo (fromInt fd, {
               rd = test(w, rdBit), 
               wr = test(w, wrBit), 
               pri = test(w, priBit)
             })
+         end
     in
     fun poll (pds, timeOut) = let
           val (fds, eventss) = ListPair.unzip (List.map fromPollDesc pds)
@@ -126,13 +130,13 @@
                       then let open PosixError in raiseSys inval end
                    else (Int.fromLarge (Time.toMilliseconds t)
                          handle Overflow => Error.raiseSys Error.inval)
-          val reventss = Array.array (n, 0w0)
+          val reventss = Array.array (n, 0)
           val _ = Posix.Error.SysCall.simpleRestart
-                  (fn () => Prim.poll (fds, eventss, n, timeOut, reventss))
+                  (fn () => Prim.poll (fds, eventss, C.NFds.fromInt n, timeOut, reventss))
           in
             Array.foldri
             (fn (i, w, l) => 
-             if w <> 0w0
+             if w <> 0
                then (toPollInfo (Vector.sub (fds, i), w))::l
                else l)
             []

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/basis/Net/NetHostDB-consts.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/basis/Net/NetHostDB-consts.c	2006-01-28 19:13:54 UTC (rev 4326)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/Net/NetHostDB-consts.c	2006-01-28 21:30:43 UTC (rev 4327)
@@ -1,4 +1,4 @@
 #include "platform.h"
 
-const C_Size_t NetHostDB_inAddrLen = sizeof (struct in_addr);
+const C_Size_t NetHostDB_inAddrSize = sizeof (struct in_addr);
 const C_Int_t NetHostDB_INADDR_ANY = INADDR_ANY;

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/basis/Net/NetHostDB.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/basis/Net/NetHostDB.c	2006-01-28 19:13:54 UTC (rev 4326)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/Net/NetHostDB.c	2006-01-28 21:30:43 UTC (rev 4327)
@@ -48,6 +48,6 @@
   return (hostent != NULL and hostent->h_name != NULL);
 }
 
-Bool NetHostDB_getHostName(Array(Char8_t) buf, C_Size_t len) {
-  return (gethostname ((char*)buf, len) == 0);
+C_Errno_t(C_Int_t) NetHostDB_getHostName(Array(Char8_t) buf, C_Size_t len) {
+  gethostname ((char*)buf, len);
 }

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/cenv.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/cenv.h	2006-01-28 19:13:54 UTC (rev 4326)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/cenv.h	2006-01-28 21:30:43 UTC (rev 4327)
@@ -24,7 +24,7 @@
 /* C99 headers */
 // #include <assert.h>
 // #include <complex.h>
-// #include <ctype.h>
+#include <ctype.h>
 #include <errno.h>
 // #include <fenv.h>
 #include <float.h>

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 19:13:54 UTC (rev 4326)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gen/basis-ffi.def	2006-01-28 21:30:43 UTC (rev 4327)
@@ -110,8 +110,8 @@
 NetHostDB.getEntryAliasesNum = _import : unit -> C.Int.t
 NetHostDB.getEntryLength = _import : unit -> C.Int.t
 NetHostDB.getEntryName = _import : unit -> C.String.t
-NetHostDB.getHostName = _import : Char8.t array * C.Size.t -> Bool.t
-NetHostDB.inAddrLen = _const : C.Size.t
+NetHostDB.getHostName = _import : Char8.t array * C.Size.t -> C.Int.t C.Errno.t
+NetHostDB.inAddrSize = _const : C.Size.t
 NetProtDB.getByName = _import : NullString8.t -> Bool.t
 NetProtDB.getByNumber = _import : C.Int.t -> Bool.t
 NetProtDB.getEntryAliasesN = _import : C.Int.t -> C.String.t
@@ -573,6 +573,9 @@
 Posix.Signal.SIGVTALRM = _const : C.Signal.t
 Posix.Signal.SIGXCPU = _const : C.Signal.t
 Posix.Signal.SIGXFSZ = _const : C.Signal.t
+Posix.Signal.SIG_BLOCK = _const : C.Int.t
+Posix.Signal.SIG_SETMASK = _const : C.Int.t
+Posix.Signal.SIG_UNBLOCK = _const : C.Int.t
 Posix.Signal.default = _import : C.Signal.t -> C.Int.t C.Errno.t
 Posix.Signal.handleGC = _import : unit -> unit
 Posix.Signal.handlee = _import : C.Signal.t -> C.Int.t C.Errno.t

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gen/gen-types.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gen/gen-types.c	2006-01-28 19:13:54 UTC (rev 4326)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gen/gen-types.c	2006-01-28 21:30:43 UTC (rev 4327)
@@ -148,6 +148,8 @@
 
 #define systype(t, bt, name)                        \
   do {                                              \
+  char *btLower = strdup(bt);                       \
+  btLower[0] = tolower(bt[0]);                      \
   writeString (cTypesHFd, "typedef ");              \
   writeString (cTypesHFd, "/* ");                   \
   writeString (cTypesHFd, #t);                      \
@@ -161,10 +163,14 @@
   writeNewline (cTypesHFd);                         \
   writeString (cTypesSMLFd, "structure ");          \
   writeString (cTypesSMLFd, name);                  \
-  writeString (cTypesSMLFd, " = ");                 \
+  writeString (cTypesSMLFd, " = struct open ");     \
   writeString (cTypesSMLFd, bt);                    \
   writeUintmaxU (cTypesSMLFd, CHAR_BIT * sizeof(t));\
+  writeString (cTypesSMLFd, " type t = ");          \
+  writeString (cTypesSMLFd, btLower);               \
+  writeString (cTypesSMLFd, " end");                \
   writeNewline (cTypesSMLFd);                       \
+  free (btLower);                                   \
   } while (0)
 #define chksystype(t, name)                \
   do {                                     \
@@ -175,6 +181,23 @@
   else                                     \
   systype(t, "Int", name);                 \
   } while (0)
+#define ptrtype(t, name)                            \
+  do {                                              \
+  writeString (cTypesHFd, "typedef ");              \
+  writeString (cTypesHFd, "/* ");                   \
+  writeString (cTypesHFd, #t);                      \
+  writeString (cTypesHFd, " */ ");                  \
+  writeString (cTypesHFd, "Pointer_t ");            \
+  writeString (cTypesHFd, "C_");                    \
+  writeString (cTypesHFd, name);                    \
+  writeString (cTypesHFd, "_t;");                   \
+  writeNewline (cTypesHFd);                         \
+  writeString (cTypesSMLFd, "structure ");          \
+  writeString (cTypesSMLFd, name);                  \
+  writeString (cTypesSMLFd, " = Pointer");          \
+  writeNewline (cTypesSMLFd);                       \
+  } while (0)
+
 #define aliastype(name1, name2)                     \
   do {                                              \
   writeString (cTypesHFd, "typedef ");              \
@@ -256,8 +279,8 @@
   chksystype(size_t, "Size");
   writeNewline (cTypesHFd);writeNewline (cTypesSMLFd);
   // systype(void*, "Word", "Pointer");
-  systype(char*, "Word", "String");
-  systype(char**, "Word", "StringArray");
+  ptrtype(char*, "String");
+  ptrtype(char**, "StringArray");
 
   writeNewline (cTypesHFd);writeNewline (cTypesSMLFd);
   writeStringWithNewline (cTypesHFd, "/* Generic integers */");
@@ -270,6 +293,7 @@
   writeNewline (cTypesHFd);writeNewline (cTypesSMLFd);
   writeStringWithNewline (cTypesHFd, "/* from <dirent.h> */");
   writeStringWithNewline (cTypesSMLFd, "(* from <dirent.h> *)");
+  // ptrtype(DIR*, "DirP");
   systype(DIR*, "Word", "DirP");
 
   writeNewline (cTypesHFd);writeNewline (cTypesSMLFd);