[MLton-commit] r4803

Matthew Fluet fluet at mlton.org
Fri Nov 3 14:47:56 PST 2006


Eliminate many uses of 'bool' from FFI in Basis Library
implementation.


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

U   mlton/branches/on-20050822-x86_64-branch/basis-library/config/c/amd64-linux/c-types.sml
A   mlton/branches/on-20050822-x86_64-branch/basis-library/config/c/word-to-bool.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/mlton/ffi.sig
U   mlton/branches/on-20050822-x86_64-branch/basis-library/mlton/ffi.sml
U   mlton/branches/on-20050822-x86_64-branch/basis-library/mlton/signal.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/posix/file-sys.sml
U   mlton/branches/on-20050822-x86_64-branch/basis-library/posix/proc-env.sml
U   mlton/branches/on-20050822-x86_64-branch/basis-library/posix/process.sml
U   mlton/branches/on-20050822-x86_64-branch/basis-library/posix/sys-db.sml
U   mlton/branches/on-20050822-x86_64-branch/basis-library/primitive/basis-ffi.sml
U   mlton/branches/on-20050822-x86_64-branch/basis-library/primitive/primitive.mlb
U   mlton/branches/on-20050822-x86_64-branch/runtime/basis/Net/NetHostDB.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/basis/Net/NetProtDB.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/basis/Net/NetServDB.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/basis/Net/Socket/INetSock.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/basis/Net/Socket/Socket.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/basis/Net/Socket/UnixSock.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/basis/Posix/FileSys/ST.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/basis/Posix/ProcEnv/isatty.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/basis/Posix/ProcEnv/setgroups.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/basis/Posix/Process/ifExited.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/basis/Posix/Process/ifSignaled.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/basis/Posix/Process/ifStopped.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/basis/Posix/Signal.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/basis/Posix/SysDB/Group.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/basis/Posix/SysDB/Passwd.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/basis/System/OS/IO/poll.c
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-11-03 11:24:54 UTC (rev 4802)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/config/c/amd64-linux/c-types.sml	2006-11-03 22:47:30 UTC (rev 4803)
@@ -7,6 +7,7 @@
 
 
 (* C *)
+structure C_Bool = WordToBool (type t = Word8.word val zero: t = 0wx0 val one: t = 0wx1)
 structure C_Char = struct open Int8 type t = int end
 functor C_Char_ChooseIntN (A: CHOOSE_INTN_ARG) = ChooseIntN_Int8 (A)
 structure C_SChar = struct open Int8 type t = int end

Added: mlton/branches/on-20050822-x86_64-branch/basis-library/config/c/word-to-bool.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library/config/c/word-to-bool.sml	2006-11-03 11:24:54 UTC (rev 4802)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/config/c/word-to-bool.sml	2006-11-03 22:47:30 UTC (rev 4803)
@@ -0,0 +1,22 @@
+(* Copyright (C) 1999-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.
+ *)
+
+functor WordToBool (S : sig
+                          eqtype t
+                          val one: t
+                          val zero: t
+                        end) : sig
+                                 eqtype t
+                                 val fromBool: bool -> t
+                                 val toBool: t -> bool
+                               end =
+   struct
+      open S
+
+      val fromBool: bool -> t = fn b => if b then zero else one
+      val toBool: t -> bool = fn w => w <> zero
+   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-11-03 11:24:54 UTC (rev 4802)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/integer/integer.sig	2006-11-03 22:47:30 UTC (rev 4803)
@@ -51,6 +51,9 @@
       include INTEGER
       type t = int
 
+      val zero: int
+      val one: int
+
       val precision' : Int.int
       val maxInt' : int
       val minInt' : int

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-11-03 11:24:54 UTC (rev 4802)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/integer/word.sig	2006-11-03 22:47:30 UTC (rev 4803)
@@ -59,6 +59,9 @@
       include WORD
       type t = word
 
+      val zero: word
+      val one: word
+
       val toWord: word -> Word.word
       val toWordX: word -> Word.word
       val fromWord: Word.word -> word

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-11-03 11:24:54 UTC (rev 4802)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/mlton/ffi.sig	2006-11-03 22:47:30 UTC (rev 4803)
@@ -9,7 +9,6 @@
    sig
       val atomicBegin: unit -> unit
       val atomicEnd: unit -> unit
-      val getBool: int -> bool
       val getChar8: int -> Char.char
 (*
       val getChar16: int -> Char16.char
@@ -27,7 +26,6 @@
       val getWord32: int -> Word32.word
       val getWord64: int -> Word64.word
       val register: int * (unit -> unit) -> unit
-      val setBool: bool -> unit
       val setChar8: Char.char -> unit
 (*
       val setChar16: Char16.char -> unit

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library/mlton/ffi.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library/mlton/ffi.sml	2006-11-03 11:24:54 UTC (rev 4802)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/mlton/ffi.sml	2006-11-03 22:47:30 UTC (rev 4803)
@@ -45,19 +45,11 @@
 val atomicEnd = MLtonThread.atomicEnd
 val register = MLtonThread.register
 
-(* To the C-world, booleans and chars are signed integers. *)
-fun intToBool (i: Int32.t): bool = i <> 0
-   
-val getBool = intToBool o getInt32
-
+(* To the C-world, chars are signed integers. *)
 val getChar8 = Primitive.Char8.idFromInt8 o getInt8
 val getChar16 = Primitive.Char16.idFromInt16 o getInt16
 val getChar32 = Primitive.Char32.idFromInt32 o getInt32
                
-fun boolToInt (b: bool): Int32.t = if b then 1 else 0
-
-val setBool = setInt32 o boolToInt
-
 val setChar8 = setInt8 o Primitive.Char8.idToInt8
 val setChar16 = setInt16 o Primitive.Char16.idToInt16
 val setChar32 = setInt32 o Primitive.Char32.idToInt32

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-11-03 11:24:54 UTC (rev 4802)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/mlton/signal.sml	2006-11-03 22:47:30 UTC (rev 4803)
@@ -109,13 +109,13 @@
 datatype handler = datatype Handler.t
 
 local
-   val r = ref false
+   val r = ref C_Int.zero
 in
    fun initHandler (s: signal): Handler.t =
       SysCall.syscallErr
       ({clear = false, restart = false, errVal = C_Int.fromInt ~1}, fn () =>
        {return = Prim.isDefault (s, r),
-        post = fn _ => if !r then Default else Ignore,
+        post = fn _ => if !r <> C_Int.zero then Default else Ignore,
         handlers = [(Error.inval, fn () => InvalidSignal)]})
 end
 
@@ -185,14 +185,18 @@
                    val () = Mask.block (handled ())
                    val fs = 
                       case !gcHandler of
-                         Handler f => if Prim.isPendingGC () then [f] else []
+                         Handler f => if Prim.isPendingGC () <> C_Int.zero 
+                                         then [f] 
+                                         else []
                        | _ => []
                    val fs =
                       Array.foldri
                       (fn (s, h, fs) =>
                        case h of
                           Handler f =>
-                             if Prim.isPending (fromInt s) then f::fs else fs
+                             if Prim.isPending (fromInt s) <> C_Int.zero
+                                then f::fs 
+                                else fs
                         | _ => fs) fs handlers
                    val () = Prim.resetPending ()
                    val () = Mask.setBlocked mask

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-11-03 11:24:54 UTC (rev 4802)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/net/net-host-db.sml	2006-11-03 22:47:30 UTC (rev 4803)
@@ -61,8 +61,8 @@
       fun addr entry = hd (addrs entry)
 
       local
-        fun get (b: bool): entry option =
-          if b
+        fun get (i: C_Int.t): entry option =
+          if i <> C_Int.zero
             then let
                    val name = CUtil.C_String.toString (Prim.getEntryName ())
                    val numAliases = Prim.getEntryAliasesNum ()

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-11-03 11:24:54 UTC (rev 4802)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/net/net-prot-db.sml	2006-11-03 22:47:30 UTC (rev 4803)
@@ -22,8 +22,8 @@
       end
 
       local
-        fun get (b: bool): entry option =
-          if b
+        fun get (i: C_Int.t): entry option =
+          if i <> C_Int.zero 
             then let
                    val name = CUtil.C_String.toString (Prim.getEntryName ())
                    val numAliases = Prim.getEntryAliasesNum ()

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-11-03 11:24:54 UTC (rev 4802)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/net/net-serv-db.sml	2006-11-03 22:47:30 UTC (rev 4803)
@@ -24,8 +24,8 @@
       end
 
       local
-        fun get (b: bool): entry option =
-          if b
+        fun get (i: C_Int.t): entry option =
+          if i <> C_Int.zero
             then let
                    val name = CUtil.C_String.toString (Prim.getEntryName ())
                    val numAliases = Prim.getEntryAliasesNum ()

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library/posix/file-sys.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library/posix/file-sys.sml	2006-11-03 11:24:54 UTC (rev 4802)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/posix/file-sys.sml	2006-11-03 22:47:30 UTC (rev 4803)
@@ -332,7 +332,7 @@
             end
 
             local
-               fun make prim s = prim (mode s)
+               fun make prim s = prim (mode s) <> C_Int.zero
             in
                val isDir = make Prim.ST.isDir
                val isChr = make Prim.ST.isChr

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library/posix/proc-env.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library/posix/proc-env.sml	2006-11-03 11:24:54 UTC (rev 4802)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/posix/proc-env.sml	2006-11-03 22:47:30 UTC (rev 4803)
@@ -256,7 +256,7 @@
 
       fun ctermid () = CS.toString (Prim.ctermid ())
 
-      fun isatty fd = Prim.isatty fd
+      fun isatty fd = (Prim.isatty fd) <> C_Int.zero
 
       fun ttyname fd =
          SysCall.syscall'

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library/posix/process.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library/posix/process.sml	2006-11-03 11:24:54 UTC (rev 4802)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/posix/process.sml	2006-11-03 22:47:30 UTC (rev 4803)
@@ -73,13 +73,13 @@
        | W_STOPPED of signal 
 
       fun fromStatus status =
-         if Prim.ifExited status
+         if Prim.ifExited status <> C_Int.zero
             then (case Prim.exitStatus status of
                      0 => W_EXITED
                    | n => W_EXITSTATUS (Word8.castFromSysWord (C_Int.castToSysWord n)))
-         else if Prim.ifSignaled status
+         else if Prim.ifSignaled status <> C_Int.zero
             then W_SIGNALED (Prim.termSig status)
-         else if Prim.ifStopped status
+         else if Prim.ifStopped status <> C_Int.zero
             then W_STOPPED (Prim.stopSig status)
          else raise Fail "Posix.Process.fromStatus"
 

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library/posix/sys-db.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library/posix/sys-db.sml	2006-11-03 11:24:54 UTC (rev 4802)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/posix/sys-db.sml	2006-11-03 22:47:30 UTC (rev 4803)
@@ -25,16 +25,21 @@
 
             structure Passwd = Prim.Passwd
 
-            fun fromC (f: unit -> bool): passwd =
-               SysCall.syscall'
-               ({errVal = false}, fn () =>
-                (C_Errno.inject (f ()),
-                 fn _ => {name = CUtil.C_String.toString (Passwd.getName ()),
-                          uid = Passwd.getUId (),
-                          gid = Passwd.getGId (),
-                          home = CUtil.C_String.toString (Passwd.getDir ()),
-                          shell = CUtil.C_String.toString (Passwd.getShell ())}))
-               
+            fun fromC (f: unit -> C_Int.t C_Errno.t, fname, fitem): passwd =
+               SysCall.syscallErr
+               ({clear = true, restart = false, errVal = C_Int.zero}, fn () =>
+                {return = f (),
+                 post = fn _ => {name = CUtil.C_String.toString (Passwd.getName ()),
+                                 uid = Passwd.getUId (),
+                                 gid = Passwd.getGId (),
+                                 home = CUtil.C_String.toString (Passwd.getDir ()),
+                                 shell = CUtil.C_String.toString (Passwd.getShell ())},
+                 handlers = [(Error.cleared, fn () => 
+                              raise Error.SysErr (concat ["Posix.SysDB.",
+                                                          fname,
+                                                          ": no group with ",
+                                                          fitem], NONE))]})
+
             val name: passwd -> string = #name
             val uid: passwd -> uid = #uid
             val gid: passwd -> gid = #gid
@@ -44,10 +49,11 @@
 
       fun getpwnam name = 
          let val name = NullString.nullTerm name
-         in Passwd.fromC (fn () => Prim.getpwnam name)
+         in Passwd.fromC (fn () => Prim.getpwnam name, "getpwnam", "name")
          end
 
-      fun getpwuid uid = Passwd.fromC (fn () => Prim.getpwuid uid)
+      fun getpwuid uid = 
+         Passwd.fromC (fn () => Prim.getpwuid uid, "getpwuid", "user id")
 
       structure Group =
          struct
@@ -57,13 +63,18 @@
 
             structure Group = Prim.Group
 
-            fun fromC (f: unit -> bool): group =
-               SysCall.syscall'
-               ({errVal = false}, fn () =>
-                (C_Errno.inject (f ()),
-                 fn _ => {name = CUtil.C_String.toString (Group.getName ()),
-                          gid = Group.getGId (),
-                          members = CUtil.C_StringArray.toList (Group.getMem ())}))
+            fun fromC (f: unit -> C_Int.t C_Errno.t, fname, fitem): group =
+               SysCall.syscallErr
+               ({clear = true, restart = false, errVal = C_Int.zero}, fn () =>
+                {return = f (),
+                 post = fn _ => {name = CUtil.C_String.toString (Group.getName ()),
+                                 gid = Group.getGId (),
+                                 members = CUtil.C_StringArray.toList (Group.getMem ())},
+                 handlers = [(Error.cleared, fn () => 
+                              raise Error.SysErr (concat ["Posix.SysDB.",
+                                                          fname,
+                                                          ": no group with ",
+                                                          fitem], NONE))]})
                   
             val name: group -> string = #name
             val gid: group -> gid = #gid
@@ -72,8 +83,9 @@
 
       fun getgrnam name = 
          let val name = NullString.nullTerm name
-         in Group.fromC (fn () => Prim.getgrnam name)
+         in Group.fromC (fn () => Prim.getgrnam name, "getgrnam", "name")
          end
       
-      fun getgrgid gid = Group.fromC (fn () => Prim.getgrgid gid)
+      fun getgrgid gid = 
+         Group.fromC (fn () => Prim.getgrgid gid, "getgrgid", "group id")
    end

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library/primitive/basis-ffi.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library/primitive/basis-ffi.sml	2006-11-03 11:24:54 UTC (rev 4802)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/primitive/basis-ffi.sml	2006-11-03 22:47:30 UTC (rev 4803)
@@ -165,8 +165,8 @@
 end
 structure NetHostDB = 
 struct
-val getByAddress = _import "NetHostDB_getByAddress" : (Word8.t) vector * C_Socklen.t -> Bool.t;
-val getByName = _import "NetHostDB_getByName" : NullString8.t -> Bool.t;
+val getByAddress = _import "NetHostDB_getByAddress" : (Word8.t) vector * C_Socklen.t -> C_Int.t;
+val getByName = _import "NetHostDB_getByName" : NullString8.t -> C_Int.t;
 val getEntryAddrsN = _import "NetHostDB_getEntryAddrsN" : C_Int.t * (Word8.t) array -> unit;
 val getEntryAddrsNum = _import "NetHostDB_getEntryAddrsNum" : unit -> C_Int.t;
 val getEntryAddrType = _import "NetHostDB_getEntryAddrType" : unit -> C_Int.t;
@@ -180,8 +180,8 @@
 end
 structure NetProtDB = 
 struct
-val getByName = _import "NetProtDB_getByName" : NullString8.t -> Bool.t;
-val getByNumber = _import "NetProtDB_getByNumber" : C_Int.t -> Bool.t;
+val getByName = _import "NetProtDB_getByName" : NullString8.t -> C_Int.t;
+val getByNumber = _import "NetProtDB_getByNumber" : C_Int.t -> C_Int.t;
 val getEntryAliasesN = _import "NetProtDB_getEntryAliasesN" : C_Int.t -> C_String.t;
 val getEntryAliasesNum = _import "NetProtDB_getEntryAliasesNum" : unit -> C_Int.t;
 val getEntryName = _import "NetProtDB_getEntryName" : unit -> C_String.t;
@@ -189,10 +189,10 @@
 end
 structure NetServDB = 
 struct
-val getByName = _import "NetServDB_getByName" : NullString8.t * NullString8.t -> Bool.t;
-val getByNameNull = _import "NetServDB_getByNameNull" : NullString8.t -> Bool.t;
-val getByPort = _import "NetServDB_getByPort" : C_Int.t * NullString8.t -> Bool.t;
-val getByPortNull = _import "NetServDB_getByPortNull" : C_Int.t -> Bool.t;
+val getByName = _import "NetServDB_getByName" : NullString8.t * NullString8.t -> C_Int.t;
+val getByNameNull = _import "NetServDB_getByNameNull" : NullString8.t -> C_Int.t;
+val getByPort = _import "NetServDB_getByPort" : C_Int.t * NullString8.t -> C_Int.t;
+val getByPortNull = _import "NetServDB_getByPortNull" : C_Int.t -> C_Int.t;
 val getEntryAliasesN = _import "NetServDB_getEntryAliasesN" : C_Int.t -> C_String.t;
 val getEntryAliasesNum = _import "NetServDB_getEntryAliasesNum" : unit -> C_Int.t;
 val getEntryName = _import "NetServDB_getEntryName" : unit -> C_String.t;
@@ -453,13 +453,13 @@
 end
 structure ST = 
 struct
-val isBlk = _import "Posix_FileSys_ST_isBlk" : C_Mode.t -> Bool.t;
-val isChr = _import "Posix_FileSys_ST_isChr" : C_Mode.t -> Bool.t;
-val isDir = _import "Posix_FileSys_ST_isDir" : C_Mode.t -> Bool.t;
-val isFIFO = _import "Posix_FileSys_ST_isFIFO" : C_Mode.t -> Bool.t;
-val isLink = _import "Posix_FileSys_ST_isLink" : C_Mode.t -> Bool.t;
-val isReg = _import "Posix_FileSys_ST_isReg" : C_Mode.t -> Bool.t;
-val isSock = _import "Posix_FileSys_ST_isSock" : C_Mode.t -> Bool.t;
+val isBlk = _import "Posix_FileSys_ST_isBlk" : C_Mode.t -> C_Int.t;
+val isChr = _import "Posix_FileSys_ST_isChr" : C_Mode.t -> C_Int.t;
+val isDir = _import "Posix_FileSys_ST_isDir" : C_Mode.t -> C_Int.t;
+val isFIFO = _import "Posix_FileSys_ST_isFIFO" : C_Mode.t -> C_Int.t;
+val isLink = _import "Posix_FileSys_ST_isLink" : C_Mode.t -> C_Int.t;
+val isReg = _import "Posix_FileSys_ST_isReg" : C_Mode.t -> C_Int.t;
+val isSock = _import "Posix_FileSys_ST_isSock" : C_Mode.t -> C_Int.t;
 end
 structure Stat = 
 struct
@@ -561,7 +561,7 @@
 val getpid = _import "Posix_ProcEnv_getpid" : unit -> C_PId.t;
 val getppid = _import "Posix_ProcEnv_getppid" : unit -> C_PId.t;
 val getuid = _import "Posix_ProcEnv_getuid" : unit -> C_UId.t;
-val isatty = _import "Posix_ProcEnv_isatty" : C_Fd.t -> Bool.t;
+val isatty = _import "Posix_ProcEnv_isatty" : C_Fd.t -> C_Int.t;
 val SC_2_C_BIND = _const "Posix_ProcEnv_SC_2_C_BIND" : C_Int.t;
 val SC_2_C_DEV = _const "Posix_ProcEnv_SC_2_C_DEV" : C_Int.t;
 val SC_2_CHAR_TERM = _const "Posix_ProcEnv_SC_2_CHAR_TERM" : C_Int.t;
@@ -719,9 +719,9 @@
 val exit = _import "Posix_Process_exit" : C_Status.t -> unit;
 val exitStatus = _import "Posix_Process_exitStatus" : C_Status.t -> C_Int.t;
 val fork = _import "Posix_Process_fork" : unit -> (C_PId.t) C_Errno.t;
-val ifExited = _import "Posix_Process_ifExited" : C_Status.t -> Bool.t;
-val ifSignaled = _import "Posix_Process_ifSignaled" : C_Status.t -> Bool.t;
-val ifStopped = _import "Posix_Process_ifStopped" : C_Status.t -> Bool.t;
+val ifExited = _import "Posix_Process_ifExited" : C_Status.t -> C_Int.t;
+val ifSignaled = _import "Posix_Process_ifSignaled" : C_Status.t -> C_Int.t;
+val ifStopped = _import "Posix_Process_ifStopped" : C_Status.t -> C_Int.t;
 val kill = _import "Posix_Process_kill" : C_PId.t * C_Signal.t -> (C_Int.t) C_Errno.t;
 val nanosleep = _import "Posix_Process_nanosleep" : (C_Time.t) ref * (C_Long.t) ref -> (C_Int.t) C_Errno.t;
 val pause = _import "Posix_Process_pause" : unit -> (C_Int.t) C_Errno.t;
@@ -742,10 +742,10 @@
 val handlee = _import "Posix_Signal_handlee" : C_Signal.t -> (C_Int.t) C_Errno.t;
 val handleGC = _import "Posix_Signal_handleGC" : unit -> unit;
 val ignore = _import "Posix_Signal_ignore" : C_Signal.t -> (C_Int.t) C_Errno.t;
-val isDefault = _import "Posix_Signal_isDefault" : C_Signal.t * (Bool.t) ref -> (C_Int.t) C_Errno.t;
-val isIgnore = _import "Posix_Signal_isIgnore" : C_Signal.t * (Bool.t) ref -> (C_Int.t) C_Errno.t;
-val isPending = _import "Posix_Signal_isPending" : C_Signal.t -> Bool.t;
-val isPendingGC = _import "Posix_Signal_isPendingGC" : unit -> Bool.t;
+val isDefault = _import "Posix_Signal_isDefault" : C_Signal.t * (C_Int.t) ref -> (C_Int.t) C_Errno.t;
+val isIgnore = _import "Posix_Signal_isIgnore" : C_Signal.t * (C_Int.t) ref -> (C_Int.t) C_Errno.t;
+val isPending = _import "Posix_Signal_isPending" : C_Signal.t -> C_Int.t;
+val isPendingGC = _import "Posix_Signal_isPendingGC" : unit -> C_Int.t;
 val NSIG = _const "Posix_Signal_NSIG" : C_Int.t;
 val resetPending = _import "Posix_Signal_resetPending" : unit -> unit;
 val SIG_BLOCK = _const "Posix_Signal_SIG_BLOCK" : C_Int.t;
@@ -789,10 +789,10 @@
 end
 structure SysDB = 
 struct
-val getgrgid = _import "Posix_SysDB_getgrgid" : C_GId.t -> Bool.t;
-val getgrnam = _import "Posix_SysDB_getgrnam" : NullString8.t -> Bool.t;
-val getpwnam = _import "Posix_SysDB_getpwnam" : NullString8.t -> Bool.t;
-val getpwuid = _import "Posix_SysDB_getpwuid" : C_GId.t -> Bool.t;
+val getgrgid = _import "Posix_SysDB_getgrgid" : C_GId.t -> (C_Int.t) C_Errno.t;
+val getgrnam = _import "Posix_SysDB_getgrnam" : NullString8.t -> (C_Int.t) C_Errno.t;
+val getpwnam = _import "Posix_SysDB_getpwnam" : NullString8.t -> (C_Int.t) C_Errno.t;
+val getpwuid = _import "Posix_SysDB_getpwuid" : C_GId.t -> (C_Int.t) C_Errno.t;
 structure Group = 
 struct
 val getGId = _import "Posix_SysDB_Group_getGId" : unit -> C_GId.t;

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library/primitive/primitive.mlb
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library/primitive/primitive.mlb	2006-11-03 11:24:54 UTC (rev 4802)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/primitive/primitive.mlb	2006-11-03 22:47:30 UTC (rev 4803)
@@ -31,6 +31,7 @@
       ../config/bind/word-prim.sml 
    in ann "forceUsed" in
       ../config/choose.sml
+      ../config/c/word-to-bool.sml
    end end
 
    prim-iwconv.sml

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-11-03 11:24:54 UTC (rev 4802)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/Net/NetHostDB.c	2006-11-03 22:47:30 UTC (rev 4803)
@@ -38,14 +38,14 @@
   return;
 }
 
-Bool_t NetHostDB_getByAddress(Vector(Word8_t) addr, C_Socklen_t len) {
+C_Int_t NetHostDB_getByAddress(Vector(Word8_t) addr, C_Socklen_t len) {
   hostent = gethostbyaddr((const char*)addr, len, AF_INET);
-  return (hostent != NULL and hostent->h_name != NULL);
+  return (C_Int_t)(hostent != NULL and hostent->h_name != NULL);
 }
 
-Bool_t NetHostDB_getByName(NullString8_t name) {
+C_Int_t NetHostDB_getByName(NullString8_t name) {
   hostent = gethostbyname((const char*)name);
-  return (hostent != NULL and hostent->h_name != NULL);
+  return (C_Int_t)(hostent != NULL and hostent->h_name != NULL);
 }
 
 C_Errno_t(C_Int_t) NetHostDB_getHostName(Array(Char8_t) buf, C_Size_t len) {

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/basis/Net/NetProtDB.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/basis/Net/NetProtDB.c	2006-11-03 11:24:54 UTC (rev 4802)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/Net/NetProtDB.c	2006-11-03 22:47:30 UTC (rev 4803)
@@ -20,12 +20,12 @@
   return protoent->p_proto;
 }
 
-Bool_t NetProtDB_getByName(NullString8_t name) {
+C_Int_t NetProtDB_getByName(NullString8_t name) {
   protoent = getprotobyname((const char*)name);
-  return (protoent != NULL and protoent->p_name != NULL);
+  return (C_Int_t)(protoent != NULL and protoent->p_name != NULL);
 }
 
-Bool_t NetProtDB_getByNumber(C_Int_t proto) {
+C_Int_t NetProtDB_getByNumber(C_Int_t proto) {
   protoent = getprotobynumber(proto);
-  return (protoent != NULL and protoent->p_name != NULL);
+  return (C_Int_t)(protoent != NULL and protoent->p_name != NULL);
 }

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/basis/Net/NetServDB.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/basis/Net/NetServDB.c	2006-11-03 11:24:54 UTC (rev 4802)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/Net/NetServDB.c	2006-11-03 22:47:30 UTC (rev 4803)
@@ -27,20 +27,20 @@
   return (C_String_t)(servent->s_proto);
 }
 
-Bool_t NetServDB_getByName(NullString8_t name, NullString8_t proto) {
+C_Int_t NetServDB_getByName(NullString8_t name, NullString8_t proto) {
   servent = getservbyname((const char*)name, (const char*)proto);
-  return (servent != NULL and servent->s_name != NULL);
+  return (C_Int_t)(servent != NULL and servent->s_name != NULL);
 }
 
-Bool_t NetServDB_getByNameNull(NullString8_t name) {
+C_Int_t NetServDB_getByNameNull(NullString8_t name) {
   return NetServDB_getByName(name, (NullString8_t)NULL);
 }
 
-Bool_t NetServDB_getByPort(C_Int_t port, NullString8_t proto) {
+C_Int_t NetServDB_getByPort(C_Int_t port, NullString8_t proto) {
   servent = getservbyport(port, (const char*)proto);
-  return (servent != NULL and servent->s_name != NULL);
+  return (C_Int_t)(servent != NULL and servent->s_name != NULL);
 }
 
-Bool_t NetServDB_getByPortNull(C_Int_t port) {
+C_Int_t NetServDB_getByPortNull(C_Int_t port) {
   return NetServDB_getByPort(port, (NullString8_t)NULL);
 }

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/basis/Net/Socket/INetSock.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/basis/Net/Socket/INetSock.c	2006-11-03 11:24:54 UTC (rev 4802)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/Net/Socket/INetSock.c	2006-11-03 22:47:30 UTC (rev 4803)
@@ -7,7 +7,7 @@
 
   sa->sin_family = AF_INET;
   sa->sin_port = port;
-  sa->sin_addr = *(struct in_addr*)in_addr;
+  sa->sin_addr = *(const struct in_addr*)in_addr;
   *((socklen_t*)addrlen) = sizeof(struct sockaddr_in);
 }
 
@@ -15,7 +15,7 @@
 static struct in_addr fromAddr_in_addr;
 
 void Socket_INetSock_fromAddr (Vector(Word8_t) addr) {
-  struct sockaddr_in *sa = (struct sockaddr_in*)addr;
+  const struct sockaddr_in *sa = (const struct sockaddr_in*)addr;
   
   assert(sa->sin_family == AF_INET);
   fromAddr_port = sa->sin_port;

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/basis/Net/Socket/Socket.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/basis/Net/Socket/Socket.c	2006-11-03 11:24:54 UTC (rev 4802)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/Net/Socket/Socket.c	2006-11-03 22:47:30 UTC (rev 4803)
@@ -7,7 +7,7 @@
 
 C_Errno_t(C_Int_t) Socket_bind (C_Sock_t s, Vector(Word8_t) addr, C_Socklen_t addrlen) {
   MLton_initSockets ();
-  return bind (s, (struct sockaddr*)addr, (socklen_t)addrlen);
+  return bind (s, (const struct sockaddr*)addr, (socklen_t)addrlen);
 }
 
 C_Errno_t(C_Int_t) Socket_close(C_Sock_t s) {
@@ -16,11 +16,11 @@
 
 C_Errno_t(C_Int_t) Socket_connect (C_Sock_t s, Vector(Word8_t) addr, C_Socklen_t addrlen) {
   MLton_initSockets ();
-  return connect (s, (struct sockaddr*)addr, (socklen_t)addrlen);
+  return connect (s, (const struct sockaddr*)addr, (socklen_t)addrlen);
 }
 
 C_Int_t Socket_familyOfAddr(Vector(Word8_t) addr) {
-  return ((struct sockaddr*)addr)->sa_family;
+  return ((const struct sockaddr*)addr)->sa_family;
 }
 
 C_Errno_t(C_Int_t) Socket_listen (C_Sock_t s, C_Int_t backlog) {
@@ -68,7 +68,7 @@
                Vector(Word8_t) addr, C_Socklen_t addrlen) {
   MLton_initSockets ();
   return sendto (s, (void*)((char *)msg + start), len, flags,
-                 (struct sockaddr*)addr, (socklen_t)addrlen);
+                 (const struct sockaddr*)addr, (socklen_t)addrlen);
 }
 
 C_Errno_t(C_SSize_t) 
@@ -100,7 +100,7 @@
 Socket_Ctl_setSockOpt (C_Sock_t s, C_Int_t level, C_Int_t optname, 
                        Vector(Word8_t) optval, C_Socklen_t optlen) {
   MLton_initSockets ();
-  return setsockopt (s, level, optname, (void*)optval, (socklen_t)optlen);
+  return setsockopt (s, level, optname, (const void*)optval, (socklen_t)optlen);
 }
 
 C_Errno_t(C_Int_t) 
@@ -112,7 +112,7 @@
 C_Errno_t(C_Int_t) 
 Socket_Ctl_setIOCtl (C_Sock_t s, C_Int_t request, Vector(Word8_t) argp) {
   MLton_initSockets ();
-  return ioctl (s, request, (void*)argp);
+  return ioctl (s, request, (const void*)argp);
 }
 
 C_Errno_t(C_Int_t) Socket_Ctl_getPeerName (C_Sock_t s, Array(Word8_t) name, Ref(C_Socklen_t) namelen) {

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/basis/Net/Socket/UnixSock.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/basis/Net/Socket/UnixSock.c	2006-11-03 11:24:54 UTC (rev 4802)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/Net/Socket/UnixSock.c	2006-11-03 22:47:30 UTC (rev 4803)
@@ -23,7 +23,7 @@
 
 C_Size_t Socket_UnixSock_pathLen (Vector(Word8_t) addr) {
   size_t i;
-  struct sockaddr_un *sa = (struct sockaddr_un*)addr;
+  const struct sockaddr_un *sa = (const struct sockaddr_un*)addr;
 
   i = 0;
   if (sa->sun_path[i] == '\000') {

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/basis/Posix/FileSys/ST.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/basis/Posix/FileSys/ST.c	2006-11-03 11:24:54 UTC (rev 4802)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/Posix/FileSys/ST.c	2006-11-03 22:47:30 UTC (rev 4803)
@@ -1,29 +1,29 @@
 #include "platform.h"
 
-Bool Posix_FileSys_ST_isBlk (C_Mode_t m) {
-  return 0 != S_ISBLK(m);
+C_Int_t Posix_FileSys_ST_isBlk (C_Mode_t m) {
+  return S_ISBLK(m);
 }
 
-Bool Posix_FileSys_ST_isChr (C_Mode_t m) {
-  return 0 != S_ISCHR(m);
+C_Int_t Posix_FileSys_ST_isChr (C_Mode_t m) {
+  return S_ISCHR(m);
 }
 
-Bool Posix_FileSys_ST_isDir (C_Mode_t m) {
-  return 0 != S_ISDIR(m);
+C_Int_t Posix_FileSys_ST_isDir (C_Mode_t m) {
+  return S_ISDIR(m);
 }
 
-Bool Posix_FileSys_ST_isFIFO (C_Mode_t m) {
-  return 0 != S_ISFIFO(m);
+C_Int_t Posix_FileSys_ST_isFIFO (C_Mode_t m) {
+  return S_ISFIFO(m);
 }
 
-Bool Posix_FileSys_ST_isLink (C_Mode_t m) {
-  return 0 != S_ISLNK(m);
+C_Int_t Posix_FileSys_ST_isLink (C_Mode_t m) {
+  return S_ISLNK(m);
 }
 
-Bool Posix_FileSys_ST_isReg (C_Mode_t m) {
-  return 0 != S_ISREG(m);
+C_Int_t Posix_FileSys_ST_isReg (C_Mode_t m) {
+  return S_ISREG(m);
 }
 
-Bool Posix_FileSys_ST_isSock (C_Mode_t m) {
-  return 0 != S_ISSOCK(m);
+C_Int_t Posix_FileSys_ST_isSock (C_Mode_t m) {
+  return S_ISSOCK(m);
 }

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/basis/Posix/ProcEnv/isatty.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/basis/Posix/ProcEnv/isatty.c	2006-11-03 11:24:54 UTC (rev 4802)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/Posix/ProcEnv/isatty.c	2006-11-03 22:47:30 UTC (rev 4803)
@@ -1,5 +1,5 @@
 #include "platform.h"
 
-Bool Posix_ProcEnv_isatty (C_Fd_t f) {
-  return 0 != isatty (f);
+C_Int_t Posix_ProcEnv_isatty (C_Fd_t f) {
+  return isatty (f);
 }

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/basis/Posix/ProcEnv/setgroups.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/basis/Posix/ProcEnv/setgroups.c	2006-11-03 11:24:54 UTC (rev 4802)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/Posix/ProcEnv/setgroups.c	2006-11-03 22:47:30 UTC (rev 4803)
@@ -1,5 +1,5 @@
 #include "platform.h"
 
 C_Errno_t(C_Int_t) Posix_ProcEnv_setgroups (C_Int_t i, Vector(C_GId_t) v) {
-  return setgroups (i, (gid_t*)v);
+  return setgroups (i, (const gid_t*)v);
 }

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/basis/Posix/Process/ifExited.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/basis/Posix/Process/ifExited.c	2006-11-03 11:24:54 UTC (rev 4802)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/Posix/Process/ifExited.c	2006-11-03 22:47:30 UTC (rev 4803)
@@ -1,8 +1,5 @@
 #include "platform.h"
 
-Bool Posix_Process_ifExited (C_Status_t s) {
-  int i;
-  
-  i = s;
-  return 0 != WIFEXITED (i);
+C_Int_t Posix_Process_ifExited (C_Status_t s) {
+  return WIFEXITED (s);
 }

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/basis/Posix/Process/ifSignaled.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/basis/Posix/Process/ifSignaled.c	2006-11-03 11:24:54 UTC (rev 4802)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/Posix/Process/ifSignaled.c	2006-11-03 22:47:30 UTC (rev 4803)
@@ -1,8 +1,5 @@
 #include "platform.h"
 
-Bool Posix_Process_ifSignaled (C_Status_t s) {
-  int i;
-  
-  i = s;
-  return 0 != WIFSIGNALED (i);
+C_Int_t Posix_Process_ifSignaled (C_Status_t s) {
+  return WIFSIGNALED (s);
 }

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/basis/Posix/Process/ifStopped.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/basis/Posix/Process/ifStopped.c	2006-11-03 11:24:54 UTC (rev 4802)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/Posix/Process/ifStopped.c	2006-11-03 22:47:30 UTC (rev 4803)
@@ -1,8 +1,5 @@
 #include "platform.h"
 
-Bool Posix_Process_ifStopped (C_Status_t s) {
-  int i;
-  
-  i = s;
-  return 0 != WIFSTOPPED (i);
+C_Int_t Posix_Process_ifStopped (C_Status_t s) {
+  return WIFSTOPPED (s);
 }

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/basis/Posix/Signal.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/basis/Posix/Signal.c	2006-11-03 11:24:54 UTC (rev 4802)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/Posix/Signal.c	2006-11-03 22:47:30 UTC (rev 4803)
@@ -24,13 +24,13 @@
   return sigaction (signum, &sa, NULL);
 }
 
-C_Errno_t(C_Int_t) Posix_Signal_isDefault (C_Int_t signum, Ref(Bool_t) isDef) {
+C_Errno_t(C_Int_t) Posix_Signal_isDefault (C_Int_t signum, Ref(C_Int_t) isDef) {
   int res;
   struct sigaction sa;
 
   sa.sa_flags = SA_FLAGS;
   res = sigaction (signum, NULL, &sa);
-  *((Bool_t*)isDef) = sa.sa_handler == SIG_DFL;
+  *((C_Int_t*)isDef) = sa.sa_handler == SIG_DFL;
   return res;
 }
 
@@ -44,13 +44,13 @@
   return sigaction (signum, &sa, NULL);
 }
 
-C_Errno_t(C_Int_t) Posix_Signal_isIgnore (C_Int_t signum, Ref(Bool_t) isIgn) {
+C_Errno_t(C_Int_t) Posix_Signal_isIgnore (C_Int_t signum, Ref(C_Int_t) isIgn) {
   int res;
   struct sigaction sa;
 
   sa.sa_flags = SA_FLAGS;
   res = sigaction (signum, NULL, &sa);
-  *((Bool_t*)isIgn) = sa.sa_handler == SIG_IGN;
+  *((C_Int_t*)isIgn) = sa.sa_handler == SIG_IGN;
   return res;
 }
 
@@ -72,11 +72,11 @@
   GC_setGCSignalHandled (&gcState, TRUE);
 }
 
-Bool_t Posix_Signal_isPending (C_Int_t signum) {
+C_Int_t Posix_Signal_isPending (C_Int_t signum) {
   return sigismember (GC_getSignalsPendingAddr (&gcState), signum);
 }
 
-Bool_t Posix_Signal_isPendingGC (void) {
+C_Int_t Posix_Signal_isPendingGC (void) {
   return GC_getGCSignalPending (&gcState);
 }
 

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/basis/Posix/SysDB/Group.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/basis/Posix/SysDB/Group.c	2006-11-03 11:24:54 UTC (rev 4802)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/Posix/SysDB/Group.c	2006-11-03 22:47:30 UTC (rev 4803)
@@ -14,10 +14,10 @@
   return (C_StringArray_t)(group->gr_mem);
 }
 
-Bool_t Posix_SysDB_getgrgid(C_GId_t g) {
+C_Errno_t(C_Int_t) Posix_SysDB_getgrgid(C_GId_t g) {
   return NULL != (group = getgrgid ((gid_t)g));
 }
 
-Bool_t Posix_SysDB_getgrnam(NullString8_t s) {
+C_Errno_t(C_Int_t) Posix_SysDB_getgrnam(NullString8_t s) {
   return NULL != (group = getgrnam ((const char*)s));
 }

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/basis/Posix/SysDB/Passwd.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/basis/Posix/SysDB/Passwd.c	2006-11-03 11:24:54 UTC (rev 4802)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/Posix/SysDB/Passwd.c	2006-11-03 22:47:30 UTC (rev 4803)
@@ -22,10 +22,10 @@
   return (C_String_t)(passwd->pw_shell);
 }
 
-Bool_t Posix_SysDB_getpwnam(NullString8_t p) {
+C_Errno_t(C_Int_t) Posix_SysDB_getpwnam(NullString8_t p) {
   return NULL != (passwd = getpwnam((const char *) p));
 }
 
-Bool_t Posix_SysDB_getpwuid(C_UId_t u) {
+C_Errno_t(C_Int_t) Posix_SysDB_getpwuid(C_UId_t u) {
   return NULL != (passwd = getpwuid(u));
 }

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/basis/System/OS/IO/poll.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/basis/System/OS/IO/poll.c	2006-11-03 11:24:54 UTC (rev 4802)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/System/OS/IO/poll.c	2006-11-03 22:47:30 UTC (rev 4803)
@@ -11,8 +11,8 @@
   struct pollfd ufds[n];
 
   for (i = 0; i < n; i++) {
-    ufds[i].fd = ((nfds_t*)fds)[i];
-    ufds[i].events = ((short*)eventss)[i];
+    ufds[i].fd = ((const int*)fds)[i];
+    ufds[i].events = ((const short*)eventss)[i];
   }
   res = poll (ufds, n, timeout);
   for (i = 0; i < n; i++) {

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-11-03 11:24:54 UTC (rev 4802)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gen/basis-ffi.def	2006-11-03 22:47:30 UTC (rev 4803)
@@ -108,8 +108,8 @@
 Net.ntohl = _import : Word32.t -> Word32.t
 Net.ntohs = _import : Word16.t -> Word16.t
 NetHostDB.INADDR_ANY = _const : C_Int.t
-NetHostDB.getByAddress = _import : Word8.t vector * C_Socklen.t -> Bool.t
-NetHostDB.getByName = _import : NullString8.t -> Bool.t
+NetHostDB.getByAddress = _import : Word8.t vector * C_Socklen.t -> C_Int.t
+NetHostDB.getByName = _import : NullString8.t -> C_Int.t
 NetHostDB.getEntryAddrType = _import : unit -> C_Int.t
 NetHostDB.getEntryAddrsN = _import : C_Int.t * Word8.t array -> unit
 NetHostDB.getEntryAddrsNum = _import : unit -> C_Int.t
@@ -119,16 +119,16 @@
 NetHostDB.getEntryName = _import : unit -> C_String.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.getByName = _import : NullString8.t -> C_Int.t
+NetProtDB.getByNumber = _import : C_Int.t -> C_Int.t
 NetProtDB.getEntryAliasesN = _import : C_Int.t -> C_String.t
 NetProtDB.getEntryAliasesNum = _import : unit -> C_Int.t
 NetProtDB.getEntryName = _import : unit -> C_String.t
 NetProtDB.getEntryProto = _import : unit -> C_Int.t
-NetServDB.getByName = _import : NullString8.t * NullString8.t -> Bool.t
-NetServDB.getByNameNull = _import : NullString8.t -> Bool.t
-NetServDB.getByPort = _import : C_Int.t * NullString8.t -> Bool.t
-NetServDB.getByPortNull = _import : C_Int.t -> Bool.t
+NetServDB.getByName = _import : NullString8.t * NullString8.t -> C_Int.t
+NetServDB.getByNameNull = _import : NullString8.t -> C_Int.t
+NetServDB.getByPort = _import : C_Int.t * NullString8.t -> C_Int.t
+NetServDB.getByPortNull = _import : C_Int.t -> C_Int.t
 NetServDB.getEntryAliasesN = _import : C_Int.t -> C_String.t
 NetServDB.getEntryAliasesNum = _import : unit -> C_Int.t
 NetServDB.getEntryName = _import : unit -> C_String.t
@@ -321,13 +321,13 @@
 Posix.FileSys.S.IXGRP = _const : C_Mode.t
 Posix.FileSys.S.IXOTH = _const : C_Mode.t
 Posix.FileSys.S.IXUSR = _const : C_Mode.t
-Posix.FileSys.ST.isBlk = _import : C_Mode.t -> Bool.t
-Posix.FileSys.ST.isChr = _import : C_Mode.t -> Bool.t
-Posix.FileSys.ST.isDir = _import : C_Mode.t -> Bool.t
-Posix.FileSys.ST.isFIFO = _import : C_Mode.t -> Bool.t
-Posix.FileSys.ST.isLink = _import : C_Mode.t -> Bool.t
-Posix.FileSys.ST.isReg = _import : C_Mode.t -> Bool.t
-Posix.FileSys.ST.isSock = _import : C_Mode.t -> Bool.t
+Posix.FileSys.ST.isBlk = _import : C_Mode.t -> C_Int.t
+Posix.FileSys.ST.isChr = _import : C_Mode.t -> C_Int.t
+Posix.FileSys.ST.isDir = _import : C_Mode.t -> C_Int.t
+Posix.FileSys.ST.isFIFO = _import : C_Mode.t -> C_Int.t
+Posix.FileSys.ST.isLink = _import : C_Mode.t -> C_Int.t
+Posix.FileSys.ST.isReg = _import : C_Mode.t -> C_Int.t
+Posix.FileSys.ST.isSock = _import : C_Mode.t -> C_Int.t
 Posix.FileSys.Stat.fstat = _import : C_Fd.t -> C_Int.t C_Errno.t
 Posix.FileSys.Stat.getATime = _import : unit -> C_Time.t
 # Posix.FileSys.Stat.getBlkCnt = _import : unit -> C_BlkCnt.t
@@ -563,7 +563,7 @@
 Posix.ProcEnv.getpid = _import : unit -> C_PId.t
 Posix.ProcEnv.getppid = _import : unit -> C_PId.t
 Posix.ProcEnv.getuid = _import : unit -> C_UId.t
-Posix.ProcEnv.isatty = _import : C_Fd.t -> Bool.t
+Posix.ProcEnv.isatty = _import : C_Fd.t -> C_Int.t
 Posix.ProcEnv.setenv = _import : NullString8.t * NullString8.t -> C_Int.t C_Errno.t
 Posix.ProcEnv.setgid = _import : C_GId.t -> C_Int.t C_Errno.t
 Posix.ProcEnv.setgroups = _import : C_Int.t * C_GId.t vector -> C_Int.t C_Errno.t
@@ -583,9 +583,9 @@
 Posix.Process.exit = _import __attribute__((noreturn)) : C_Status.t -> unit
 Posix.Process.exitStatus = _import : C_Status.t -> C_Int.t
 Posix.Process.fork = _import : unit -> C_PId.t C_Errno.t
-Posix.Process.ifExited = _import : C_Status.t -> Bool.t
-Posix.Process.ifSignaled = _import : C_Status.t -> Bool.t
-Posix.Process.ifStopped = _import : C_Status.t -> Bool.t
+Posix.Process.ifExited = _import : C_Status.t -> C_Int.t
+Posix.Process.ifSignaled = _import : C_Status.t -> C_Int.t
+Posix.Process.ifStopped = _import : C_Status.t -> C_Int.t
 Posix.Process.kill = _import : C_PId.t * C_Signal.t -> C_Int.t C_Errno.t
 Posix.Process.nanosleep = _import : C_Time.t ref * C_Long.t ref -> C_Int.t C_Errno.t
 Posix.Process.pause = _import : unit -> C_Int.t C_Errno.t
@@ -630,10 +630,10 @@
 Posix.Signal.handleGC = _import : unit -> unit
 Posix.Signal.handlee = _import : C_Signal.t -> C_Int.t C_Errno.t
 Posix.Signal.ignore = _import : C_Signal.t -> C_Int.t C_Errno.t
-Posix.Signal.isDefault = _import : C_Signal.t * Bool.t ref -> C_Int.t C_Errno.t
-Posix.Signal.isIgnore = _import : C_Signal.t * Bool.t ref -> C_Int.t C_Errno.t
-Posix.Signal.isPending = _import : C_Signal.t -> Bool.t
-Posix.Signal.isPendingGC = _import : unit -> Bool.t
+Posix.Signal.isDefault = _import : C_Signal.t * C_Int.t ref -> C_Int.t C_Errno.t
+Posix.Signal.isIgnore = _import : C_Signal.t * C_Int.t ref -> C_Int.t C_Errno.t
+Posix.Signal.isPending = _import : C_Signal.t -> C_Int.t
+Posix.Signal.isPendingGC = _import : unit -> C_Int.t
 Posix.Signal.resetPending = _import :unit -> unit
 Posix.Signal.sigaddset = _import : C_Signal.t -> C_Int.t C_Errno.t
 Posix.Signal.sigdelset = _import : C_Signal.t -> C_Int.t C_Errno.t
@@ -650,10 +650,10 @@
 Posix.SysDB.Passwd.getName = _import : unit -> C_String.t
 Posix.SysDB.Passwd.getShell = _import : unit -> C_String.t
 Posix.SysDB.Passwd.getUId = _import : unit -> C_UId.t
-Posix.SysDB.getgrgid = _import : C_GId.t -> Bool.t
-Posix.SysDB.getgrnam = _import : NullString8.t -> Bool.t
-Posix.SysDB.getpwnam = _import : NullString8.t -> Bool.t
-Posix.SysDB.getpwuid = _import : C_GId.t -> Bool.t
+Posix.SysDB.getgrgid = _import : C_GId.t -> C_Int.t C_Errno.t
+Posix.SysDB.getgrnam = _import : NullString8.t -> C_Int.t C_Errno.t
+Posix.SysDB.getpwnam = _import : NullString8.t -> C_Int.t C_Errno.t
+Posix.SysDB.getpwuid = _import : C_GId.t -> C_Int.t C_Errno.t
 Posix.TTY.B0 = _const : C_Speed.t
 Posix.TTY.B110 = _const : C_Speed.t
 Posix.TTY.B1200 = _const : C_Speed.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-11-03 11:24:54 UTC (rev 4802)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gen/gen-types.c	2006-11-03 22:47:30 UTC (rev 4803)
@@ -63,15 +63,15 @@
 
 static const char* mlTypesHStd[] = {
   "/* ML types */",
-  // "typedef void* Pointer;",
-  // "typedef uintptr_t Pointer;",
-  // "typedef unsigned char* Pointer;",
-  // "struct PointerAux { unsigned char z[4]; } __attribute__ ((aligned (4), may_alias));",
+  "// typedef void* Pointer;",
+  "// typedef uintptr_t Pointer;",
+  "// typedef unsigned char* Pointer;",
+  "// struct PointerAux { unsigned char z[4]; } __attribute__ ((aligned (4), may_alias));",
   "typedef unsigned char PointerAux __attribute__ ((aligned (4), may_alias));",
   "typedef PointerAux* Pointer;",
   "#define Array(t) Pointer",
   "#define Ref(t) Pointer",
-  "#define Vector(t) const Pointer",
+  "#define Vector(t) Pointer",
   "",
   "typedef int8_t Int8_t;",
   "typedef int8_t Int8;",
@@ -147,6 +147,33 @@
   NULL
 };
 
+#define booltype(t, bt, name)                       \
+  do {                                              \
+  writeString (cTypesHFd, "typedef ");              \
+  writeString (cTypesHFd, #t);                      \
+  writeString (cTypesHFd, " /* ");                  \
+  writeString (cTypesHFd, bt);                      \
+  writeUintmaxU (cTypesHFd, CHAR_BIT * sizeof(t));  \
+  writeString (cTypesHFd, "_t");                    \
+  writeString (cTypesHFd, " */ ");                  \
+  writeString (cTypesHFd, "C_");                    \
+  writeString (cTypesHFd, name);                    \
+  writeString (cTypesHFd, "_t;");                   \
+  writeNewline (cTypesHFd);                         \
+  writeString (cTypesSMLFd, "structure C_");        \
+  writeString (cTypesSMLFd, name);                  \
+  writeString (cTypesSMLFd, " = WordToBool (");     \
+  writeString (cTypesSMLFd, "type t = ");           \
+  writeString (cTypesSMLFd, "Word");                \
+  writeUintmaxU (cTypesSMLFd, CHAR_BIT * sizeof(t));\
+  writeString (cTypesSMLFd, ".word");               \
+  writeString (cTypesSMLFd, " ");                   \
+  writeString (cTypesSMLFd, "val zero: t = 0wx0");  \
+  writeString (cTypesSMLFd, " ");                   \
+  writeString (cTypesSMLFd, "val one: t = 0wx1");   \
+  writeString (cTypesSMLFd, ")");                   \
+  writeNewline (cTypesSMLFd);                       \
+  } while (0)
 #define systype(t, bt, name)                        \
   do {                                              \
   char *btLower = strdup(bt);                       \
@@ -156,12 +183,12 @@
   for (size_t i = 0; i < strlen(btUpper); i++)      \
     btUpper[i] = (char)(toupper((int)(bt[i])));     \
   writeString (cTypesHFd, "typedef ");              \
-  writeString (cTypesHFd, "/* ");                   \
   writeString (cTypesHFd, #t);                      \
-  writeString (cTypesHFd, " */ ");                  \
+  writeString (cTypesHFd, " /* ");                  \
   writeString (cTypesHFd, bt);                      \
   writeUintmaxU (cTypesHFd, CHAR_BIT * sizeof(t));  \
-  writeString (cTypesHFd, "_t ");                   \
+  writeString (cTypesHFd, "_t");                    \
+  writeString (cTypesHFd, " */ ");                  \
   writeString (cTypesHFd, "C_");                    \
   writeString (cTypesHFd, name);                    \
   writeString (cTypesHFd, "_t;");                   \
@@ -203,10 +230,10 @@
 #define ptrtype(t, name)                            \
   do {                                              \
   writeString (cTypesHFd, "typedef ");              \
-  writeString (cTypesHFd, "/* ");                   \
   writeString (cTypesHFd, #t);                      \
+  writeString (cTypesHFd, " /* ");                  \
+  writeString (cTypesHFd, "Pointer");               \
   writeString (cTypesHFd, " */ ");                  \
-  writeString (cTypesHFd, "Pointer ");              \
   writeString (cTypesHFd, "C_");                    \
   writeString (cTypesHFd, name);                    \
   writeString (cTypesHFd, "_t;");                   \
@@ -298,6 +325,7 @@
   writeNewline (cTypesHFd);writeNewline (cTypesSMLFd);
   writeStringWithNewline (cTypesHFd, "/* C */");
   writeStringWithNewline (cTypesSMLFd, "(* C *)");
+  booltype(_Bool, "Word", "Bool");
   chksystype(char, "Char");
   chksystype(signed char, "SChar");
   chksystype(unsigned char, "UChar");




More information about the MLton-commit mailing list