[MLton-commit] r4423

Matthew Fluet MLton@mlton.org
Thu, 27 Apr 2006 08:48:08 -0700


Working on Flags
----------------------------------------------------------------------

U   mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/build/sources.mlb
U   mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/int-inf.sig
U   mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/int-inf.sml
U   mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/int-inf0.sml
U   mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/int.sml
U   mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/int1.sml
U   mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/integer.sig
U   mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/word.sig
U   mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/word.sml
U   mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/word0.sml
U   mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/word1.sml
U   mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/posix/file-sys.sml
U   mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/posix/flags.sig
U   mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/posix/flags.sml
U   mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/prim-word.sml
U   mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/primitive.mlb

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

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/build/sources.mlb
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/build/sources.mlb	2006-04-26 02:25:30 UTC (rev 4422)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/build/sources.mlb	2006-04-27 15:48:05 UTC (rev 4423)
@@ -29,6 +29,8 @@
       ../config/header/$(HEADER_WORD)
       ../config/seq/$(SEQ_INDEX)
       ../config/c/misc/$(CTYPES)
+      ../config/c/position.sml
+      ../config/c/sys-word.sml
    end end
    ../integer/int-inf0.sml
    local
@@ -117,6 +119,8 @@
    in ann "forceUsed" in
       ../config/objptr/$(OBJPTR_REP)
       ../config/c/misc/$(CTYPES)
+      ../config/c/position.sml
+      ../config/c/sys-word.sml
    end end
    ../integer/int-inf.sig
    ../integer/int-inf.sml
@@ -146,6 +150,8 @@
       ../config/bind/word-top.sml 
    in ann "forceUsed" in
       ../config/c/misc/$(CTYPES)
+      ../config/c/position.sml
+      ../config/c/sys-word.sml
    end end
 
    ../text/char.sig
@@ -214,7 +220,7 @@
 
    ../posix/stub-mingw.sml
    ../posix/flags.sig
-   ../posix/flags.sml
+   (* ../posix/flags.sml *)
    ../posix/signal.sig
    ../posix/signal.sml
    ../posix/proc-env.sig

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/int-inf.sig
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/int-inf.sig	2006-04-26 02:25:30 UTC (rev 4422)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/int-inf.sig	2006-04-27 15:48:05 UTC (rev 4423)
@@ -17,6 +17,7 @@
 signature INT_INF_EXTRA =
    sig
       include INT_INF
+      type t = int
 
       structure BigWord : WORD
       structure SmallInt : INTEGER

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/int-inf.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/int-inf.sml	2006-04-26 02:25:30 UTC (rev 4422)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/int-inf.sml	2006-04-27 15:48:05 UTC (rev 4423)
@@ -9,6 +9,7 @@
 structure IntInf: INT_INF_EXTRA =
    struct
       open Primitive.IntInf
+      type t = int
 
       structure BigWord = C_MPLimb
       structure SmallInt = ObjptrInt

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/int-inf0.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/int-inf0.sml	2006-04-26 02:25:30 UTC (rev 4422)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/int-inf0.sml	2006-04-27 15:48:05 UTC (rev 4423)
@@ -1072,6 +1072,7 @@
       open Word8
       val fromIntInfUnsafe = IntInf.toWord8Unsafe
       val fromIntInf = IntInf.toWord8
+      val fromIntInfZ = IntInf.toWord8
       val toIntInfUnsafe = IntInf.fromWord8Unsafe
       val toIntInf = IntInf.fromWord8
       val toIntInfXUnsafe = IntInf.fromWord8XUnsafe
@@ -1082,6 +1083,7 @@
       open Word16
       val fromIntInfUnsafe = IntInf.toWord16Unsafe
       val fromIntInf = IntInf.toWord16
+      val fromIntInfZ = IntInf.toWord16
       val toIntInfUnsafe = IntInf.fromWord16Unsafe
       val toIntInf = IntInf.fromWord16
       val toIntInfXUnsafe = IntInf.fromWord16XUnsafe
@@ -1092,6 +1094,7 @@
       open Word32
       val fromIntInfUnsafe = IntInf.toWord32Unsafe
       val fromIntInf = IntInf.toWord32
+      val fromIntInfZ = IntInf.toWord32
       val toIntInfUnsafe = IntInf.fromWord32Unsafe
       val toIntInf = IntInf.fromWord32
       val toIntInfXUnsafe = IntInf.fromWord32XUnsafe
@@ -1102,6 +1105,7 @@
       open Word64
       val fromIntInfUnsafe = IntInf.toWord64Unsafe
       val fromIntInf = IntInf.toWord64
+      val fromIntInfZ = IntInf.toWord64
       val toIntInfUnsafe = IntInf.fromWord64Unsafe
       val toIntInf = IntInf.fromWord64
       val toIntInfXUnsafe = IntInf.fromWord64XUnsafe

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/int.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/int.sml	2006-04-26 02:25:30 UTC (rev 4422)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/int.sml	2006-04-27 15:48:05 UTC (rev 4423)
@@ -10,6 +10,7 @@
 struct
 
 open I
+type t = int
 
 val precision': Int.int = Primitive.Int32.toInt precision'
 val precision: Int.int option = SOME precision'

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/int1.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/int1.sml	2006-04-26 02:25:30 UTC (rev 4422)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/int1.sml	2006-04-27 15:48:05 UTC (rev 4423)
@@ -38,13 +38,19 @@
 signature INT_FROM_TO_RES =
    sig
       type int
+
       val fromIntUnsafe: Int.int -> int
+      val fromInt: Int.int -> int
+      val fromLargeIntUnsafe: LargeInt.int -> int
       val fromLargeUnsafe: LargeInt.int -> int
-      val fromInt: Int.int -> int
+      val fromLargeInt: LargeInt.int -> int
       val fromLarge: LargeInt.int -> int
+
       val toIntUnsafe: int -> Int.int
+      val toInt: int -> Int.int
+      val toLargeIntUnsafe: int -> LargeInt.int
       val toLargeUnsafe: int -> LargeInt.int
-      val toInt: int -> Int.int
+      val toLargeInt: int -> LargeInt.int
       val toLarge: int -> LargeInt.int
    end
 
@@ -66,18 +72,6 @@
       end
       local
          structure S =
-            LargeInt_ChooseInt
-            (type 'a t = 'a -> int
-             val fInt8 = I.fromInt8Unsafe
-             val fInt16 = I.fromInt16Unsafe
-             val fInt32 = I.fromInt32Unsafe
-             val fInt64 = I.fromInt64Unsafe
-             val fIntInf = I.fromIntInfUnsafe)
-      in
-         val fromLargeUnsafe = S.f
-      end
-      local
-         structure S =
             Int_ChooseInt
             (type 'a t = 'a -> int
              val fInt8 = I.fromInt8
@@ -92,14 +86,29 @@
          structure S =
             LargeInt_ChooseInt
             (type 'a t = 'a -> int
+             val fInt8 = I.fromInt8Unsafe
+             val fInt16 = I.fromInt16Unsafe
+             val fInt32 = I.fromInt32Unsafe
+             val fInt64 = I.fromInt64Unsafe
+             val fIntInf = I.fromIntInfUnsafe)
+      in
+         val fromLargeIntUnsafe = S.f
+         val fromLargeUnsafe = fromLargeIntUnsafe
+      end
+      local
+         structure S =
+            LargeInt_ChooseInt
+            (type 'a t = 'a -> int
              val fInt8 = I.fromInt8
              val fInt16 = I.fromInt16
              val fInt32 = I.fromInt32
              val fInt64 = I.fromInt64
              val fIntInf = I.fromIntInf)
       in
-         val fromLarge = S.f
+         val fromLargeInt = S.f
+         val fromLarge = fromLargeInt
       end
+
       local
          structure S =
             Int_ChooseInt
@@ -114,18 +123,6 @@
       end
       local
          structure S =
-            LargeInt_ChooseInt
-            (type 'a t = int -> 'a
-             val fInt8 = I.toInt8Unsafe
-             val fInt16 = I.toInt16Unsafe
-             val fInt32 = I.toInt32Unsafe
-             val fInt64 = I.toInt64Unsafe
-             val fIntInf = I.toIntInfUnsafe)
-      in
-         val toLargeUnsafe = S.f
-      end
-      local
-         structure S =
             Int_ChooseInt
             (type 'a t = int -> 'a
              val fInt8 = I.toInt8
@@ -140,15 +137,28 @@
          structure S =
             LargeInt_ChooseInt
             (type 'a t = int -> 'a
+             val fInt8 = I.toInt8Unsafe
+             val fInt16 = I.toInt16Unsafe
+             val fInt32 = I.toInt32Unsafe
+             val fInt64 = I.toInt64Unsafe
+             val fIntInf = I.toIntInfUnsafe)
+      in
+         val toLargeIntUnsafe = S.f
+         val toLargeUnsafe = toLargeIntUnsafe
+      end
+      local
+         structure S =
+            LargeInt_ChooseInt
+            (type 'a t = int -> 'a
              val fInt8 = I.toInt8
              val fInt16 = I.toInt16
              val fInt32 = I.toInt32
              val fInt64 = I.toInt64
              val fIntInf = I.toIntInf)
       in
-         val toLarge = S.f
+         val toLargeInt = S.f
+         val toLarge = toLargeInt
       end
-
    end
 
 structure Primitive = struct

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/integer.sig
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/integer.sig	2006-04-26 02:25:30 UTC (rev 4422)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/integer.sig	2006-04-27 15:48:05 UTC (rev 4423)
@@ -89,6 +89,7 @@
 signature INTEGER_EXTRA =
    sig
       include INTEGER
+      type t = int
 
       val precision' : Int.int
       val maxInt' : int

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/word.sig
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/word.sig	2006-04-26 02:25:30 UTC (rev 4422)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/word.sig	2006-04-27 15:48:05 UTC (rev 4423)
@@ -51,8 +51,13 @@
       val wordSizeWord: Primitive.Word32.word
 
       val fromWord: Word.word -> word
+      val fromWordX: Word.word -> word
+      val fromSysWord: SysWord.word -> word
+      val fromSysWordX: SysWord.word -> word
       val toWord: word -> Word.word
       val toWordX: word -> Word.word
+      val toSysWord: word -> SysWord.word
+      val toSysWordX: word -> SysWord.word
 
       val << : word * Primitive.Word32.word -> word
       val >> : word * Primitive.Word32.word -> word
@@ -83,11 +88,18 @@
 signature WORD_EXTRA =
    sig
       include WORD
+      type t = word
+
       val wordSizeWord: Word.word
 
       val fromWord: Word.word -> word
+      val fromWordX: Word.word -> word
+      val fromSysWord: SysWord.word -> word
+      val fromSysWordX: SysWord.word -> word
       val toWord: word -> Word.word
       val toWordX: word -> Word.word
+      val toSysWord: word -> SysWord.word
+      val toSysWordX: word -> SysWord.word
 
       val rol: word * Word.word -> word
       val ror: word * Word.word -> word

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/word.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/word.sml	2006-04-26 02:25:30 UTC (rev 4422)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/word.sml	2006-04-27 15:48:05 UTC (rev 4423)
@@ -10,6 +10,7 @@
 struct
 
 open W
+type t = word
 
 val wordSize: Int.int = Primitive.Int32.toInt wordSize
 val wordSizeWord: Word.word = Primitive.Word32.toWord wordSizeWord

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/word0.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/word0.sml	2006-04-26 02:25:30 UTC (rev 4422)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/word0.sml	2006-04-27 15:48:05 UTC (rev 4423)
@@ -31,13 +31,11 @@
       val fromInt32: Primitive.Int32.int -> word
       val fromInt64: Primitive.Int64.int -> word
 
-(*
       (* Lowbits or zero extend. *)
       val fromInt8Z: Primitive.Int8.int -> word
       val fromInt16Z: Primitive.Int16.int -> word
       val fromInt32Z: Primitive.Int32.int -> word
       val fromInt64Z: Primitive.Int64.int -> word
-*)
 
       (* Lowbits or zero extend. *)
       val fromWord8: Primitive.Word8.word -> word
@@ -146,7 +144,7 @@
          end
 
       local
-         fun 'a make {fromIntUnsafe: 'a -> word, (* fromIntZUnsafe: 'a -> word, *)
+         fun 'a make {fromIntUnsafe: 'a -> word, fromIntZUnsafe: 'a -> word,
                       toIntUnsafe: word -> 'a, toIntXUnsafe: word -> 'a,
                       other : {precision': Primitive.Int32.int,
                                maxInt': 'a,
@@ -167,38 +165,38 @@
                      else toIntXUnsafe w
             in
                (fromIntUnsafe,
-                (* fromIntZUnsafe, *)
+                fromIntZUnsafe,
                 toInt,
                 toIntX)
             end
       in
-         val (fromInt8, (* fromInt8Z, *) toInt8, toInt8X) = 
+         val (fromInt8, fromInt8Z, toInt8, toInt8X) = 
             make {fromIntUnsafe = fromInt8Unsafe,
-                  (* fromIntZUnsafe = fromInt8ZUnsafe, *)
+                   fromIntZUnsafe = fromInt8ZUnsafe, 
                   toIntUnsafe = toInt8Unsafe,
                   toIntXUnsafe = toInt8XUnsafe,
                   other = {precision' = Primitive.Int8.precision',
                            maxInt' = Primitive.Int8.maxInt',
                            minInt' = Primitive.Int8.minInt'}}
-         val (fromInt16, (* fromInt16Z, *) toInt16, toInt16X) = 
+         val (fromInt16, fromInt16Z, toInt16, toInt16X) = 
             make {fromIntUnsafe = fromInt16Unsafe,
-                  (* fromIntZUnsafe = fromInt16ZUnsafe, *)
+                   fromIntZUnsafe = fromInt16ZUnsafe, 
                   toIntUnsafe = toInt16Unsafe,
                   toIntXUnsafe = toInt16XUnsafe,
                   other = {precision' = Primitive.Int16.precision',
                            maxInt' = Primitive.Int16.maxInt',
                            minInt' = Primitive.Int16.minInt'}}
-         val (fromInt32, (* fromInt32Z, *) toInt32, toInt32X) = 
+         val (fromInt32, fromInt32Z, toInt32, toInt32X) = 
             make {fromIntUnsafe = fromInt32Unsafe,
-                  (* fromIntZUnsafe = fromInt32ZUnsafe, *)
+                   fromIntZUnsafe = fromInt32ZUnsafe, 
                   toIntUnsafe = toInt32Unsafe,
                   toIntXUnsafe = toInt32XUnsafe,
                   other = {precision' = Primitive.Int32.precision',
                            maxInt' = Primitive.Int32.maxInt',
                            minInt' = Primitive.Int32.minInt'}}
-         val (fromInt64, (* fromInt64Z, *) toInt64, toInt64X) = 
+         val (fromInt64, fromInt64Z, toInt64, toInt64X) = 
             make {fromIntUnsafe = fromInt64Unsafe,
-                  (* fromIntZUnsafe = fromInt64ZUnsafe, *)
+                  fromIntZUnsafe = fromInt64ZUnsafe, 
                   toIntUnsafe = toInt64Unsafe,
                   toIntXUnsafe = toInt64XUnsafe,
                   other = {precision' = Primitive.Int64.precision',

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/word1.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/word1.sml	2006-04-26 02:25:30 UTC (rev 4422)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/word1.sml	2006-04-27 15:48:05 UTC (rev 4423)
@@ -16,10 +16,21 @@
       val fromInt64: Primitive.Int64.int -> word
       val fromIntInf: Primitive.IntInf.int -> word
       (* Lowbits or zero extend. *)
+      val fromInt8Z: Primitive.Int8.int -> word
+      val fromInt16Z: Primitive.Int16.int -> word
+      val fromInt32Z: Primitive.Int32.int -> word
+      val fromInt64Z: Primitive.Int64.int -> word
+      val fromIntInfZ: Primitive.IntInf.int -> word
+      (* Lowbits or zero extend. *)
       val fromWord8: Primitive.Word8.word -> word
       val fromWord16: Primitive.Word16.word -> word
       val fromWord32: Primitive.Word32.word -> word
       val fromWord64: Primitive.Word64.word -> word
+      (* Lowbits or sign extend. *)
+      val fromWord8X: Primitive.Word8.word -> word
+      val fromWord16X: Primitive.Word16.word -> word
+      val fromWord32X: Primitive.Word32.word -> word
+      val fromWord64X: Primitive.Word64.word -> word
       (* Overflow checking, unsigned interp. *)
       val toInt8: word -> Primitive.Int8.int
       val toInt16: word -> Primitive.Int16.int
@@ -49,21 +60,30 @@
       type word
 
       val fromInt: Int.int -> word
+      val fromIntZ: Int.int -> word
+      val fromLargeInt: LargeInt.int -> word
+      val fromLargeIntZ: LargeInt.int -> word
       val fromWord: Word.word -> word
+      val fromWordX: Word.word -> word
+      val fromLargeWord: LargeWord.word -> word
       val fromLarge: LargeWord.word -> word
-      val fromLargeInt: LargeInt.int -> word
-      val fromLargeWord: LargeWord.word -> word
+      val fromLargeWordX: LargeWord.word -> word
+      val fromLargeX: LargeWord.word -> word
+      val fromSysWord: SysWord.word -> word
+      val fromSysWordX: SysWord.word -> word
 
       val toInt: word -> Int.int
       val toIntX: word -> Int.int
+      val toLargeInt: word -> LargeInt.int
+      val toLargeIntX: word -> LargeInt.int
       val toWord: word -> Word.word
       val toWordX: word -> Word.word
+      val toLargeWord: word -> LargeWord.word
       val toLarge: word -> LargeWord.word
+      val toLargeWordX: word -> LargeWord.word
       val toLargeX: word -> LargeWord.word
-      val toLargeInt: word -> LargeInt.int
-      val toLargeIntX: word -> LargeInt.int
-      val toLargeWord: word -> LargeWord.word
-      val toLargeWordX: word -> LargeWord.word
+      val toSysWord: word -> SysWord.word
+      val toSysWordX: word -> SysWord.word
    end
 
 functor WordFromTo (W: WORD_FROM_TO_ARG): WORD_FROM_TO_RES where type word = W.word =
@@ -84,6 +104,18 @@
       end
       local
          structure S =
+            Int_ChooseInt
+            (type 'a t = 'a -> word
+             val fInt8 = W.fromInt8Z
+             val fInt16 = W.fromInt16Z
+             val fInt32 = W.fromInt32Z
+             val fInt64 = W.fromInt64Z
+             val fIntInf = W.fromIntInfZ)
+      in
+         val fromIntZ = S.f
+      end
+      local
+         structure S =
             LargeInt_ChooseInt
             (type 'a t = 'a -> word
              val fInt8 = W.fromInt8
@@ -96,6 +128,18 @@
       end
       local
          structure S =
+            LargeInt_ChooseInt
+            (type 'a t = 'a -> word
+             val fInt8 = W.fromInt8Z
+             val fInt16 = W.fromInt16Z
+             val fInt32 = W.fromInt32Z
+             val fInt64 = W.fromInt64Z
+             val fIntInf = W.fromIntInfZ)
+      in
+         val fromLargeIntZ = S.f
+      end
+      local
+         structure S =
             Word_ChooseWordN
             (type 'a t = 'a -> word
              val fWord8 = W.fromWord8
@@ -107,6 +151,17 @@
       end
       local
          structure S =
+            Word_ChooseWordN
+            (type 'a t = 'a -> word
+             val fWord8 = W.fromWord8X
+             val fWord16 = W.fromWord16X
+             val fWord32 = W.fromWord32X
+             val fWord64 = W.fromWord64X)
+      in
+         val fromWordX = S.f
+      end
+      local
+         structure S =
             LargeWord_ChooseWordN
             (type 'a t = 'a -> word
              val fWord8 = W.fromWord8
@@ -114,9 +169,43 @@
              val fWord32 = W.fromWord32
              val fWord64 = W.fromWord64)
       in
-         val fromLarge = S.f
-         val fromLargeWord = fromLarge
+         val fromLargeWord = S.f
+         val fromLarge = fromLargeWord
       end
+      local
+         structure S =
+            LargeWord_ChooseWordN
+            (type 'a t = 'a -> word
+             val fWord8 = W.fromWord8X
+             val fWord16 = W.fromWord16X
+             val fWord32 = W.fromWord32X
+             val fWord64 = W.fromWord64X)
+      in
+         val fromLargeWordX = S.f
+         val fromLargeX = fromLargeWordX
+      end
+      local
+         structure S =
+            SysWord_ChooseWordN
+            (type 'a t = 'a -> word
+             val fWord8 = W.fromWord8
+             val fWord16 = W.fromWord16
+             val fWord32 = W.fromWord32
+             val fWord64 = W.fromWord64)
+      in
+         val fromSysWord = S.f
+      end
+      local
+         structure S =
+            SysWord_ChooseWordN
+            (type 'a t = 'a -> word
+             val fWord8 = W.fromWord8X
+             val fWord16 = W.fromWord16X
+             val fWord32 = W.fromWord32X
+             val fWord64 = W.fromWord64X)
+      in
+         val fromSysWordX = S.f
+      end
 
       local
          structure S =
@@ -179,6 +268,17 @@
       end
       local
          structure S =
+            Word_ChooseWordN
+            (type 'a t = word -> 'a
+             val fWord8 = W.toWord8X
+             val fWord16 = W.toWord16X
+             val fWord32 = W.toWord32X
+             val fWord64 = W.toWord64X)
+      in
+         val toWordX = S.f
+      end
+      local
+         structure S =
             LargeWord_ChooseWordN
             (type 'a t = word -> 'a
              val fWord8 = W.toWord8
@@ -186,34 +286,43 @@
              val fWord32 = W.toWord32
              val fWord64 = W.toWord64)
       in
-         val toLarge = S.f
-         val toLargeWord = toLarge
+         val toLargeWord = S.f
+         val toLarge = toLargeWord
       end
       local
          structure S =
-            Word_ChooseWordN
+            LargeWord_ChooseWordN
             (type 'a t = word -> 'a
              val fWord8 = W.toWord8X
              val fWord16 = W.toWord16X
              val fWord32 = W.toWord32X
              val fWord64 = W.toWord64X)
       in
-         val toWordX = S.f
+         val toLargeWordX = S.f
+         val toLargeX = toLargeWordX
       end
       local
          structure S =
-            LargeWord_ChooseWordN
+            SysWord_ChooseWordN
             (type 'a t = word -> 'a
+             val fWord8 = W.toWord8
+             val fWord16 = W.toWord16
+             val fWord32 = W.toWord32
+             val fWord64 = W.toWord64)
+      in
+         val toSysWord = S.f
+      end
+      local
+         structure S =
+            SysWord_ChooseWordN
+            (type 'a t = word -> 'a
              val fWord8 = W.toWord8X
              val fWord16 = W.toWord16X
              val fWord32 = W.toWord32X
              val fWord64 = W.toWord64X)
       in
-         val toLargeX = S.f
-         val toLargeWordX = toLargeX
+         val toSysWordX = S.f
       end
-
-
    end
 
 structure Primitive = struct

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/posix/file-sys.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/posix/file-sys.sml	2006-04-26 02:25:30 UTC (rev 4422)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/posix/file-sys.sml	2006-04-27 15:48:05 UTC (rev 4423)
@@ -28,7 +28,6 @@
       structure Prim = PrimitiveFFI.Posix.FileSys
       open Prim
       structure Stat = Prim.Stat
-      structure Flags = BitFlags
 
       type file_desc = C_Fd.t
       type uid = C_UId.t
@@ -152,7 +151,13 @@
 
       structure S =
          struct
-            open S Flags
+            open S 
+            local 
+               structure Flags = BitFlags(structure W = C_Mode
+                                          val all = 0wxFFFF)
+            in
+               open Flags
+            end
             type mode = C_Mode.t
             val ifblk = IFBLK
             val ifchr = IFCHR
@@ -182,20 +187,20 @@
       structure O =
          struct
             open O Flags
-            val append = SysWord.fromInt APPEND
-            val binary = SysWord.fromInt BINARY
-            val creat = SysWord.fromInt CREAT
-            val dsync = SysWord.fromInt DSYNC
-            val excl = SysWord.fromInt EXCL
-            val noctty = SysWord.fromInt NOCTTY
-            val nonblock = SysWord.fromInt NONBLOCK
-            val rdonly = SysWord.fromInt RDONLY
-            val rdwr = SysWord.fromInt RDWR
-            val rsync = SysWord.fromInt RSYNC
-            val sync = SysWord.fromInt SYNC
-            val text = SysWord.fromInt TEXT
-            val trunc = SysWord.fromInt TRUNC
-            val wronly = SysWord.fromInt WRONLY
+            val append = APPEND
+            val binary = BINARY
+            val creat = CREAT
+            val dsync = DSYNC
+            val excl = EXCL
+            val noctty = NOCTTY
+            val nonblock = NONBLOCK
+            val rdonly = RDONLY
+            val rdwr = RDWR
+            val rsync = RSYNC
+            val sync = SYNC
+            val text = TEXT
+            val trunc = TRUNC
+            val wronly = WRONLY
          end
 
       datatype open_mode = O_RDONLY | O_WRONLY | O_RDWR

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/posix/flags.sig
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/posix/flags.sig	2006-04-26 02:25:30 UTC (rev 4422)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/posix/flags.sig	2006-04-27 15:48:05 UTC (rev 4423)
@@ -1,3 +1,11 @@
+(* Copyright (C) 1999-2006 Henry Cejtin, Matthew Fluet, Suresh
+ *    Jagannathan, and Stephen Weeks.
+ * Copyright (C) 1997-2000 NEC Research Institute.
+ *
+ * MLton is released under a BSD-style license.
+ * See the file MLton-LICENSE for details.
+ *)
+
 signature BIT_FLAGS =
    sig
       eqtype flags

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/posix/flags.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/posix/flags.sml	2006-04-26 02:25:30 UTC (rev 4422)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/posix/flags.sml	2006-04-27 15:48:05 UTC (rev 4423)
@@ -6,25 +6,28 @@
  * See the file MLton-LICENSE for details.
  *)
 
-functor BitFlags(val all: SysWord.word): BIT_FLAGS_EXTRA =
+functor BitFlags(structure S : sig
+                    type t
+                    val all: t
+                    val toSysWord: t -> SysWord.word
+                    val fromSysWord: SysWord.word -> t
+                 end): BIT_FLAGS_EXTRA =
    struct
-      type flags = SysWord.word
+      type flags = S.t
          
-      val all: flags = all
-      val empty: flags = 0w0
+      val all: flags = S.all
+      val empty: flags = S.fromSysWord 0w0
 
-      fun toWord f = f
-      fun fromWord f = SysWord.andb(f, all)
+      fun toWord f = W.toSysWord f
+      fun fromWord w = W.fromSysWord (SysWord.andb(w, toWord all))
 
-      val flags: flags list -> flags = List.foldl SysWord.orb empty
+      val flags: flags list -> flags = List.foldl W.orb empty
 
-      val intersect: flags list -> flags = List.foldl SysWord.andb all
+      val intersect: flags list -> flags = List.foldl W.andb all
 
-      fun clear(f, f') = SysWord.andb(SysWord.notb f, f')
+      fun clear(f, f') = W.andb(W.notb f, f')
 
-      fun allSet(f, f') = SysWord.andb(f, f') = f
+      fun allSet(f, f') = W.andb(f, f') = f
 
-      fun anySet(f, f') = SysWord.andb(f, f') <> 0w0
-
+      fun anySet(f, f') = W.andb(f, f') <> empty
    end
-structure BitFlags = BitFlags(val all = 0wxFFFF: SysWord.word)

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/prim-word.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/prim-word.sml	2006-04-26 02:25:30 UTC (rev 4422)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/prim-word.sml	2006-04-27 15:48:05 UTC (rev 4423)
@@ -45,13 +45,11 @@
       val fromInt32Unsafe: Primitive.Int32.int -> word
       val fromInt64Unsafe: Primitive.Int64.int -> word
 
-(*
       (* Lowbits or zero extend. *)
       val fromInt8ZUnsafe: Primitive.Int8.int -> word
       val fromInt16ZUnsafe: Primitive.Int16.int -> word
       val fromInt32ZUnsafe: Primitive.Int32.int -> word
       val fromInt64ZUnsafe: Primitive.Int64.int -> word
-*)
 
       (* Lowbits or zero extend. *)
       val fromWord8Unsafe: Primitive.Word8.word -> word
@@ -179,12 +177,10 @@
       val fromInt32Unsafe = _prim "WordS32_toWord8": Int32.int -> word;
       val fromInt64Unsafe = _prim "WordS64_toWord8": Int64.int -> word;
 
-(*
       val fromInt8ZUnsafe = _prim "WordU8_toWord8": Int8.int -> word;
       val fromInt16ZUnsafe = _prim "WordU16_toWord8": Int16.int -> word;
       val fromInt32ZUnsafe = _prim "WordU32_toWord8": Int32.int -> word;
       val fromInt64ZUnsafe = _prim "WordU64_toWord8": Int64.int -> word;
-*)
 
       val fromWord8Unsafe = _prim "WordU8_toWord8": Word8.word -> word;
       val fromWord16Unsafe = _prim "WordU16_toWord8": Word16.word -> word;
@@ -310,12 +306,10 @@
       val fromInt32Unsafe = _prim "WordS32_toWord16": Int32.int -> word;
       val fromInt64Unsafe = _prim "WordS64_toWord16": Int64.int -> word;
 
-(*
       val fromInt8ZUnsafe = _prim "WordU8_toWord16": Int8.int -> word;
       val fromInt16ZUnsafe = _prim "WordU16_toWord16": Int16.int -> word;
       val fromInt32ZUnsafe = _prim "WordU32_toWord16": Int32.int -> word;
       val fromInt64ZUnsafe = _prim "WordU64_toWord16": Int64.int -> word;
-*)
 
       val fromWord8Unsafe = _prim "WordU8_toWord16": Word8.word -> word;
       val fromWord16Unsafe = _prim "WordU16_toWord16": Word16.word -> word;
@@ -505,12 +499,10 @@
       val fromInt32Unsafe = _prim "WordS32_toWord32": Int32.int -> word;
       val fromInt64Unsafe = _prim "WordS64_toWord32": Int64.int -> word;
 
-(*
       val fromInt8ZUnsafe = _prim "WordU8_toWord32": Int8.int -> word;
       val fromInt16ZUnsafe = _prim "WordU16_toWord32": Int16.int -> word;
       val fromInt32ZUnsafe = _prim "WordU32_toWord32": Int32.int -> word;
       val fromInt64ZUnsafe = _prim "WordU64_toWord32": Int64.int -> word;
-*)
 
       val fromWord8Unsafe = _prim "WordU8_toWord32": Word8.word -> word;
       val fromWord16Unsafe = _prim "WordU16_toWord32": Word16.word -> word;
@@ -580,12 +572,10 @@
       val fromInt32Unsafe = _prim "WordS32_toWord64": Int32.int -> word;
       val fromInt64Unsafe = _prim "WordS64_toWord64": Int64.int -> word;
 
-(*
       val fromInt8ZUnsafe = _prim "WordU8_toWord64": Int8.int -> word;
       val fromInt16ZUnsafe = _prim "WordU16_toWord64": Int16.int -> word;
       val fromInt32ZUnsafe = _prim "WordU32_toWord64": Int32.int -> word;
       val fromInt64ZUnsafe = _prim "WordU64_toWord64": Int64.int -> word;
-*)
 
       val fromWord8Unsafe = _prim "WordU8_toWord64": Word8.word -> word;
       val fromWord16Unsafe = _prim "WordU16_toWord64": Word16.word -> word;

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/primitive.mlb
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/primitive.mlb	2006-04-26 02:25:30 UTC (rev 4422)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/primitive.mlb	2006-04-27 15:48:05 UTC (rev 4423)
@@ -45,8 +45,10 @@
       ../config/objptr/$(OBJPTR_REP)
       ../config/header/$(HEADER_WORD)
       ../config/seq/$(SEQ_INDEX)
+      ../config/c/misc/$(CTYPES)
       ../config/c/errno.sml
-      ../config/c/misc/$(CTYPES)
+      ../config/c/position.sml
+      ../config/c/sys-word.sml
    end end
    prim-seq.sml
    prim-nullstring.sml