[MLton-commit] r4425
Matthew Fluet
MLton@mlton.org
Sun, 30 Apr 2006 11:58:10 -0700
Refactored Posix
----------------------------------------------------------------------
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/config/c/errno.sml
U mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/posix/io.sml
U mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/posix/process.sml
U mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/posix/sys-db.sml
U mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/posix/tty.sml
U mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/basis-ffi.sml
U mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/prim1.sml
U mlton/branches/on-20050822-x86_64-branch/runtime/Posix/IO/fcntl-consts.c
U mlton/branches/on-20050822-x86_64-branch/runtime/gen/basis-ffi.def
----------------------------------------------------------------------
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-30 14:07:24 UTC (rev 4424)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/build/sources.mlb 2006-04-30 18:58:08 UTC (rev 4425)
@@ -228,15 +228,15 @@
../posix/file-sys.sig
../posix/file-sys.sml
../posix/io.sig
- (* ../posix/io.sml *)
+ ../posix/io.sml
../posix/process.sig
- (* ../posix/process.sml *)
+ ../posix/process.sml
../posix/sys-db.sig
- (* ../posix/sys-db.sml *)
+ ../posix/sys-db.sml
../posix/tty.sig
- (* ../posix/tty.sml *)
- (* ../posix/posix.sig *)
- (* ../posix/posix.sml *)
+ ../posix/tty.sml
+ ../posix/posix.sig
+ ../posix/posix.sml
(*
../../platform/cygwin.sml
Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/config/c/errno.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/config/c/errno.sml 2006-04-30 14:07:24 UTC (rev 4424)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/config/c/errno.sml 2006-04-30 18:58:08 UTC (rev 4425)
@@ -9,8 +9,10 @@
sig
type 'a t
val check: 'a t -> 'a
+ val inject: 'a -> 'a t
end =
struct
type 'a t = 'a
val check = fn x => x
+ val inject = fn x => x
end
Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/posix/io.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/posix/io.sml 2006-04-30 14:07:24 UTC (rev 4424)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/posix/io.sml 2006-04-30 18:58:08 UTC (rev 4425)
@@ -15,24 +15,21 @@
structure SysCall = Error.SysCall
structure FS = PosixFileSys
-type file_desc = C_Fd.t
+type file_desc = C_Fd.t (* = C_Int.t *)
type pid = C_PId.t
-val FD = C_Fd.fromInt
-val unFD = C_Fd.toInt
-
local
- val a: file_desc array = Array.array (2, FD 0)
+ val a: file_desc array = Array.array (2, C_Fd.fromInt 0)
in
fun pipe () =
SysCall.syscall
(fn () =>
(Prim.pipe a,
- fn () => {infd = Array.sub (a, 0),
- outfd = Array.sub (a, 1)}))
+ fn _ => {infd = Array.sub (a, 0),
+ outfd = Array.sub (a, 1)}))
end
-fun dup fd = FD (SysCall.simpleResult (fn () => Prim.dup fd))
+fun dup fd = SysCall.simpleResult (fn () => Prim.dup fd)
fun dup2 {new, old} = SysCall.simple (fn () => Prim.dup2 (old, new))
@@ -40,8 +37,9 @@
structure FD =
struct
- open FD BitFlags
- val cloexec = SysWord.fromInt CLOEXEC
+ structure Flags = BitFlags(structure S = C_Int)
+ open FD Flags
+ val cloexec = CLOEXEC
end
structure O = PosixFileSys.O
@@ -49,30 +47,28 @@
datatype open_mode = datatype PosixFileSys.open_mode
fun dupfd {base, old} =
- FD (SysCall.simpleResultRestart
- (fn () => Prim.fcntl3 (old, F_DUPFD, unFD base)))
+ SysCall.simpleResultRestart
+ (fn () => Prim.fcntl3 (old, F_DUPFD, base))
fun getfd fd =
- Word.fromInt (SysCall.simpleResultRestart
- (fn () => Prim.fcntl2 (fd, F_GETFD)))
+ SysCall.simpleResultRestart
+ (fn () => Prim.fcntl2 (fd, F_GETFD))
fun setfd (fd, flags): unit =
SysCall.simpleRestart
- (fn () => Prim.fcntl3 (fd, F_SETFD, Word.toIntX flags))
+ (fn () => Prim.fcntl3 (fd, F_SETFD, flags))
fun getfl fd : O.flags * open_mode =
let
- val n =
- SysCall.simpleResultRestart (fn () => Prim.fcntl2 (fd, F_GETFL))
- val w = Word.fromInt n
- val flags = Word.andb (w, Word.notb (Word.fromInt O_ACCMODE))
- val mode = Word.andb (w, (Word.fromInt O_ACCMODE))
- in (flags, PosixFileSys.wordToOpenMode mode)
+ val n = SysCall.simpleResultRestart (fn () => Prim.fcntl2 (fd, F_GETFL))
+ val flags = C_Int.andb (n, C_Int.notb O_ACCMODE)
+ val mode = C_Int.andb (n, O_ACCMODE)
+ in (flags, PosixFileSys.flagsToOpenMode mode)
end
fun setfl (fd, flags: O.flags): unit =
SysCall.simpleRestart
- (fn () => Prim.fcntl3 (fd, F_SETFL, Word.toIntX flags))
+ (fn () => Prim.fcntl3 (fd, F_SETFL, flags))
datatype whence = SEEK_SET | SEEK_CUR | SEEK_END
@@ -82,11 +78,9 @@
| SEEK_END => Prim.SEEK_END
fun lseek (fd, n: Position.int, w: whence): Position.int =
- SysCall.syscall
- (fn () =>
- let val n = Prim.lseek (fd, n, whenceToInt w)
- in (if n = ~1 then ~1 else 0, fn () => n)
- end)
+ SysCall.simpleResult'
+ ({errVal = C_Off.fromInt ~1}, fn () =>
+ Prim.lseek (fd, n, whenceToInt w))
fun fsync fd : unit = SysCall.simple (fn () => Prim.fsync fd)
@@ -99,15 +93,12 @@
if n = Prim.FLock.SEEK_SET
then SEEK_SET
else if n = Prim.FLock.SEEK_CUR
- then SEEK_CUR
- else if n = Prim.FLock.SEEK_END
- then SEEK_END
- else raise Fail "Posix.IO.intToWhence"
+ then SEEK_CUR
+ else if n = Prim.FLock.SEEK_END
+ then SEEK_END
+ else raise Fail "Posix.IO.intToWhence"
-datatype lock_type =
- F_RDLCK
- | F_WRLCK
- | F_UNLCK
+datatype lock_type = F_RDLCK | F_WRLCK | F_UNLCK
val lockTypeToInt =
fn F_RDLCK => Prim.FLock.F_RDLCK
@@ -118,10 +109,10 @@
if n = Prim.FLock.F_RDLCK
then F_RDLCK
else if n = Prim.FLock.F_WRLCK
- then F_WRLCK
- else if n = Prim.FLock.F_UNLCK
- then F_UNLCK
- else raise Fail "Posix.IO.intToLockType"
+ then F_WRLCK
+ else if n = Prim.FLock.F_UNLCK
+ then F_UNLCK
+ else raise Fail "Posix.IO.intToLockType"
structure FLock =
struct
@@ -153,7 +144,7 @@
; P.setWhence (whenceToInt whence)
; P.setStart start
; P.setLen len
- ; P.fcntl (fd, cmd)), fn () =>
+ ; P.fcntl (fd, cmd)), fn _ =>
{ltype = intToLockType (P.getType ()),
whence = intToWhence (P.getWhence ()),
start = P.getStart (),
@@ -210,9 +201,12 @@
endPos = NONE,
verifyPos = NONE}
- fun make {RD, WR, fromVector, read, setMode, toArraySlice, toVectorSlice,
- vectorLength, write, writeVec} =
+ fun make {RD, WR, fromVector, readArr, setMode, toArraySlice, toVectorSlice,
+ vectorLength, writeArr, writeVec} =
let
+ val primReadArr = readArr
+ val primWriteArr = writeArr
+ val primWriteVec = writeVec
val setMode =
fn fd =>
if let
@@ -227,35 +221,49 @@
fun readArr (fd, sl): int =
let
val (buf, i, sz) = ArraySlice.base (toArraySlice sl)
+ val bytesRead =
+ SysCall.simpleResultRestart'
+ ({errVal = C_SSize.fromInt ~1}, fn () =>
+ primReadArr (fd, buf, C_Int.fromInt i, C_Size.fromInt sz))
+ val bytesRead = C_SSize.toInt bytesRead
in
- SysCall.simpleResultRestart (fn () => read (fd, buf, i, C_Size.fromInt sz))
+ bytesRead
end
fun readVec (fd, n) =
let
- val a = Primitive.Array.array n
+ val buf = Array.arrayUninit n
val bytesRead =
- SysCall.simpleResultRestart (fn () => read (fd, a, 0, C_Size.fromInt n))
+ SysCall.simpleResultRestart'
+ ({errVal = C_SSize.fromInt ~1}, fn () =>
+ primReadArr (fd, buf, C_Int.fromInt 0, C_Size.fromInt n))
+ val bytesRead = C_SSize.toInt bytesRead
in
fromVector
(if n = bytesRead
- then Vector.fromArray a
- else ArraySlice.vector (ArraySlice.slice
- (a, 0, SOME bytesRead)))
+ then Vector.fromArray buf
+ else ArraySlice.vector (ArraySlice.slice (buf, 0, SOME bytesRead)))
end
- fun writeArr (fd, sl) =
+ fun writeArr (fd, sl): int =
let
val (buf, i, sz) = ArraySlice.base (toArraySlice sl)
+ val bytesWrote =
+ SysCall.simpleResultRestart'
+ ({errVal = C_SSize.fromInt ~1}, fn () =>
+ primWriteArr (fd, buf, C_Int.fromInt i, C_Size.fromInt sz))
+ val bytesWrote = C_SSize.toInt bytesWrote
in
- SysCall.simpleResultRestart
- (fn () => write (fd, buf, i, C_Size.fromInt sz))
+ bytesWrote
end
- val writeVec =
- fn (fd, sl) =>
+ fun writeVec (fd, sl): int =
let
val (buf, i, sz) = VectorSlice.base (toVectorSlice sl)
+ val bytesWrote =
+ SysCall.simpleResultRestart'
+ ({errVal = C_SSize.fromInt ~1}, fn () =>
+ primWriteVec (fd, buf, C_Int.fromInt i, C_Size.fromInt sz))
+ val bytesWrote = C_SSize.toInt bytesWrote
in
- SysCall.simpleResultRestart
- (fn () => writeVec (fd, buf, i, C_Size.fromInt sz))
+ bytesWrote
end
fun mkReader {fd, name, initBlkMode} =
let
@@ -304,7 +312,7 @@
RD {avail = avail,
block = NONE,
canInput = NONE,
- chunkSize = Primitive.TextIO.bufSize,
+ chunkSize = Int32.toInt Primitive.Controls.bufSize,
close = close,
endPos = endPos,
getPos = getPos,
@@ -378,23 +386,23 @@
make {RD = BinPrimIO.RD,
WR = BinPrimIO.WR,
fromVector = Word8Vector.fromPoly,
- read = readWord8,
+ readArr = readWord8,
setMode = Prim.setbin,
toArraySlice = Word8ArraySlice.toPoly,
toVectorSlice = Word8VectorSlice.toPoly,
vectorLength = Word8Vector.length,
- write = writeWord8Arr,
+ writeArr = writeWord8Arr,
writeVec = writeWord8Vec}
val {mkReader = mkTextReader, mkWriter = mkTextWriter, ...} =
make {RD = TextPrimIO.RD,
WR = TextPrimIO.WR,
fromVector = fn v => v,
- read = readChar8,
+ readArr = readChar8,
setMode = Prim.settext,
toArraySlice = CharArraySlice.toPoly,
toVectorSlice = CharVectorSlice.toPoly,
vectorLength = CharVector.length,
- write = writeChar8Arr,
+ writeArr = writeChar8Arr,
writeVec = writeChar8Vec}
end
Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/posix/process.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/posix/process.sml 2006-04-30 14:07:24 UTC (rev 4424)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/posix/process.sml 2006-04-30 18:58:08 UTC (rev 4425)
@@ -14,19 +14,16 @@
structure SysCall = Error.SysCall
type signal = PosixSignal.signal
- type pid = Pid.t
+ type pid = C_PId.t
- val wordToPid = Pid.fromInt o SysWord.toInt
- val pidToWord = SysWord.fromInt o Pid.toInt
+ val wordToPid = C_PId.fromSysWord
+ val pidToWord = C_PId.toSysWord
fun fork () =
- SysCall.syscall
- (fn () =>
- let
- val p = Prim.fork ()
- val p' = Pid.toInt p
- in (p', fn () => if p' = 0 then NONE else SOME p)
- end)
+ SysCall.syscall'
+ ({errVal = C_PId.fromInt ~1}, fn () =>
+ (Prim.fork (), fn p =>
+ if p = C_PId.fromInt 0 then NONE else SOME p))
val fork =
if Primitive.MLton.Platform.OS.forkIsEnabled
@@ -34,7 +31,7 @@
else fn () => Error.raiseSys Error.nosys
val conv = NullString.nullTerm
- val convs = COld.CSS.fromList
+ val convs = CUtil.C_StringArray.fromList
fun exece (path, args, env): 'a =
let
@@ -76,7 +73,7 @@
if Prim.ifExited status
then (case Prim.exitStatus status of
0 => W_EXITED
- | n => W_EXITSTATUS (Word8.fromInt n))
+ | n => W_EXITSTATUS (Word8.fromSysWord (C_Int.toSysWord n)))
else if Prim.ifSignaled status
then W_SIGNALED (Prim.termSig status)
else if Prim.ifStopped status
@@ -85,10 +82,11 @@
structure W =
struct
- open W BitFlags
- val continued = SysWord.fromInt CONTINUED
- val nohang = SysWord.fromInt NOHANG
- val untraced = SysWord.fromInt UNTRACED
+ structure Flags = BitFlags(structure S = C_Int)
+ open W Flags
+ val continued = CONTINUED
+ val nohang = NOHANG
+ val untraced = UNTRACED
end
local
@@ -98,24 +96,23 @@
val useCwait =
Primitive.MLton.Platform.OS.useWindowsProcess
andalso case wa of W_CHILD _ => true | _ => false
- val p =
+ val pid =
case wa of
- W_ANY_CHILD => ~1
- | W_CHILD pid => Pid.toInt pid
- | W_SAME_GROUP => 0
- | W_GROUP pid => ~ (Pid.toInt pid)
+ W_ANY_CHILD => C_PId.fromInt ~1
+ | W_CHILD pid => pid
+ | W_SAME_GROUP => C_PId.fromInt 0
+ | W_GROUP pid => C_PId.~ pid
val flags = W.flags flags
in
- SysCall.syscallRestart
- (fn () =>
+ SysCall.simpleResultRestart'
+ ({errVal = C_PId.fromInt ~1}, fn () =>
let
val pid =
if useCwait
- then PrimitiveFFI.MLton.Process.cwait (Pid.fromInt p, status)
- else Prim.waitpid (Pid.fromInt p, status,
- SysWord.toInt flags)
+ then PrimitiveFFI.MLton.Process.cwait (pid, status)
+ else Prim.waitpid (pid, status, flags)
in
- (Pid.toInt pid, fn () => pid)
+ pid
end)
end
fun getStatus () = fromStatus (!status)
@@ -131,7 +128,7 @@
let
val pid = wait (wa, status, W.nohang :: flags)
in
- if 0 = Pid.toInt pid
+ if C_PId.fromInt 0 = pid
then NONE
else SOME (pid, getStatus ())
end
@@ -143,7 +140,7 @@
(* Posix.Process.exit does not call atExit cleaners, as per the basis
* library spec.
*)
- (Prim.exit (Word8.toInt w)
+ (Prim.exit (C_Status.fromSysWord (Word8.toSysWord w))
; raise Fail "Posix.Process.exit")
datatype killpid_arg =
@@ -155,22 +152,20 @@
let
val pid =
case ka of
- K_PROC pid => Pid.toInt pid
- | K_SAME_GROUP => ~1
- | K_GROUP pid => ~ (Pid.toInt pid)
+ K_PROC pid => pid
+ | K_SAME_GROUP => C_PId.fromInt ~1
+ | K_GROUP pid => C_PId.~ pid
in
- SysCall.simple (fn () => Prim.kill (Pid.fromInt pid, s))
+ SysCall.simple (fn () => Prim.kill (pid, s))
end
local
fun wrap prim (t: Time.time): Time.time =
Time.fromSeconds
- (LargeInt.fromInt
- (C_UInt.toInt
- (prim
- (C_UInt.fromInt
- (LargeInt.toInt (Time.toSeconds t)
- handle Overflow => Error.raiseSys Error.inval)))))
+ (C_UInt.toLargeInt
+ (prim
+ ((C_UInt.fromLargeInt (Time.toSeconds t))
+ handle Overflow => Error.raiseSys Error.inval)))
in
val alarm = wrap Prim.alarm
(* val sleep = wrap Prim.sleep *)
@@ -178,18 +173,20 @@
fun sleep (t: Time.time): Time.time =
let
- val (sec, nsec) = IntInf.quotRem (Time.toNanoseconds t, 1000000000)
+ val t = Time.toNanoseconds t
+ val sec = LargeInt.quot (t, 1000000000)
+ val nsec = LargeInt.rem (t, 1000000000)
val (sec, nsec) =
- (IntInf.toInt sec, IntInf.toInt nsec)
+ (C_Time.fromLarge sec, C_Long.fromLarge nsec)
handle Overflow => Error.raiseSys Error.inval
val secRem = ref sec
val nsecRem = ref nsec
- fun remaining () =
- Time.+ (Time.fromSeconds (Int.toLarge (!secRem)),
- Time.fromNanoseconds (Int.toLarge (!nsecRem)))
+ fun remaining _ =
+ Time.+ (Time.fromSeconds (C_Time.toLarge (!secRem)),
+ Time.fromNanoseconds (C_Long.toLarge (!nsecRem)))
in
SysCall.syscallErr
- ({clear = false, restart = false}, fn () =>
+ ({clear = false, restart = false, errVal = C_Int.fromInt ~1}, fn () =>
{handlers = [(Error.intr, remaining)],
post = remaining,
return = Prim.nanosleep (secRem, nsecRem)})
@@ -198,9 +195,9 @@
(* FIXME: pause *)
fun pause () =
SysCall.syscallErr
- ({clear = false, restart = false},
+ ({clear = false, restart = false, errVal = C_Int.fromInt ~1},
fn () =>
{return = Prim.pause (),
- post = fn () => (),
+ post = fn _ => (),
handlers = [(Error.intr, fn () => ())]})
end
Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/posix/sys-db.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/posix/sys-db.sml 2006-04-30 14:07:24 UTC (rev 4424)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/posix/sys-db.sml 2006-04-30 18:58:08 UTC (rev 4425)
@@ -8,7 +8,6 @@
structure PosixSysDB: POSIX_SYS_DB =
struct
- structure CS = COld.CS
structure Prim = PrimitiveFFI.Posix.SysDB
structure Error = PosixError
structure SysCall = Error.SysCall
@@ -27,14 +26,14 @@
structure Passwd = Prim.Passwd
fun fromC (f: unit -> bool): passwd =
- SysCall.syscall
- (fn () =>
- (if f () then 0 else ~1,
- fn () => {name = CS.toString(Passwd.getName ()),
- uid = Passwd.getUId (),
- gid = Passwd.getGId (),
- home = CS.toString(Passwd.getDir ()),
- shell = CS.toString(Passwd.getShell ())}))
+ 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 ())}))
val name: passwd -> string = #name
val uid: passwd -> uid = #uid
@@ -59,12 +58,12 @@
structure Group = Prim.Group
fun fromC (f: unit -> bool): group =
- SysCall.syscall
- (fn () =>
- (if f () then 0 else ~1,
- fn () => {name = CS.toString(Group.getName ()),
- gid = Group.getGId (),
- members = COld.CSS.toList(Group.getMem ())}))
+ 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 ())}))
val name: group -> string = #name
val gid: group -> gid = #gid
Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/posix/tty.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/posix/tty.sml 2006-04-30 14:07:24 UTC (rev 4424)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/posix/tty.sml 2006-04-30 18:58:08 UTC (rev 4425)
@@ -8,7 +8,6 @@
structure PosixTTY: POSIX_TTY =
struct
- structure Cstring = COld.CS
structure Prim = PrimitiveFFI.Posix.TTY
open Prim
structure Error = PosixError
@@ -21,27 +20,29 @@
structure V =
struct
open V
- val nccs = NCCS
- val eof = VEOF
- val eol = VEOL
- val erase = VERASE
- val intr = VINTR
- val kill = VKILL
- val min = VMIN
- val quit = VQUIT
- val susp = VSUSP
- val time = VTIME
- val start = VSTART
- val stop = VSTOP
+ val nccs = C_Int.toInt NCCS
+ val eof = C_Int.toInt VEOF
+ val eol = C_Int.toInt VEOL
+ val erase = C_Int.toInt VERASE
+ val intr = C_Int.toInt VINTR
+ val kill = C_Int.toInt VKILL
+ val min = C_Int.toInt VMIN
+ val quit = C_Int.toInt VQUIT
+ val susp = C_Int.toInt VSUSP
+ val time = C_Int.toInt VTIME
+ val start = C_Int.toInt VSTART
+ val stop = C_Int.toInt VSTOP
type cc = C_CC.t array
- val default = Byte.charToByte #"\000"
+ val default = C_CC.fromSysWord 0w0
- fun new () = Array.array (NCCS, default)
+ fun new () = Array.array (nccs, default)
fun updates (a, l) =
- List.app (fn (i, cc) => Array.update (a, i, Byte.charToByte cc)) l
+ List.app (fn (i, cc) =>
+ Array.update (a, i, (C_CC.fromSysWord o Word8.toSysWord o Byte.charToByte) cc))
+ l
fun cc l = let val a = new ()
in updates (a, l)
@@ -55,12 +56,13 @@
; a'
end
- val sub = Byte.byteToChar o Array.sub
+ val sub = (Byte.byteToChar o Word8.fromSysWord o C_CC.toSysWord) o Array.sub
end
+ structure Flags = BitFlags(structure S = C_TCFlag)
structure I =
struct
- open I BitFlags
+ open I Flags
val brkint = BRKINT
val icrnl = ICRNL
val ignbrk = IGNBRK
@@ -77,7 +79,7 @@
structure O =
struct
- open O BitFlags
+ open O Flags
val bs0 = BS0
val bs1 = BS1
val bsdly = BSDLY
@@ -110,7 +112,7 @@
structure C =
struct
- open C BitFlags
+ open C Flags
val clocal = CLOCAL
val cread = CREAD
val cs5 = CS5
@@ -126,7 +128,7 @@
structure L =
struct
- open L BitFlags
+ open L Flags
val echo = ECHO
val echoe = ECHOE
val echok = ECHOK
@@ -157,10 +159,9 @@
val b75 = B75
val b9600 = B9600
- val compareSpeed = SysWord.compare
- fun id x = x
- val speedToWord = id
- val wordToSpeed = id
+ val compareSpeed = C_Speed.compare
+ val speedToWord = C_Speed.toSysWord
+ val wordToSpeed = C_Speed.fromSysWord
type termios = {iflag: I.flags,
oflag: O.flags,
@@ -170,6 +171,7 @@
ispeed: speed,
ospeed: speed}
+ val id = fn x => x
val termios = id
val fieldsOf = id
@@ -230,7 +232,7 @@
fun getattr fd =
SysCall.syscallRestart
(fn () =>
- (Prim.TC.getattr fd, fn () =>
+ (Prim.TC.getattr fd, fn _ =>
{iflag = Termios.getIFlag (),
oflag = Termios.getOFlag (),
cflag = Termios.getCFlag (),
@@ -252,10 +254,10 @@
; SysCall.simple (fn () => Termios.cfSetOSpeed ospeed)
; SysCall.simple (fn () => Termios.cfSetISpeed ispeed)
; Termios.setCC cc
- ; (Prim.TC.setattr (fd, a), fn () => ())))
+ ; (Prim.TC.setattr (fd, a), fn _ => ())))
fun sendbreak (fd, n) =
- SysCall.simpleRestart (fn () => Prim.TC.sendbreak (fd, n))
+ SysCall.simpleRestart (fn () => Prim.TC.sendbreak (fd, C_Int.fromInt n))
fun drain fd = SysCall.simpleRestart (fn () => Prim.TC.drain fd)
@@ -266,11 +268,9 @@
SysCall.simpleRestart (fn () => Prim.TC.flow (fd, n))
fun getpgrp fd =
- SysCall.syscallRestart
- (fn () =>
- let val pid = Prim.TC.getpgrp fd
- in (Pid.toInt pid, fn () => pid)
- end)
+ SysCall.simpleResultRestart'
+ ({errVal = C_PId.fromInt ~1}, fn () =>
+ Prim.TC.getpgrp fd)
fun setpgrp (fd, pid) =
SysCall.simpleRestart (fn () => Prim.TC.setpgrp (fd, pid))
Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/basis-ffi.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/basis-ffi.sml 2006-04-30 14:07:24 UTC (rev 4424)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/basis-ffi.sml 2006-04-30 18:58:08 UTC (rev 4425)
@@ -499,7 +499,7 @@
val fcntl3 = _import "Posix_IO_fcntl3" : C_Fd.t * C_Int.t * C_Int.t -> (C_Int.t) C_Errno.t;
structure FD =
struct
-val CLOEXEC = _const "Posix_IO_FD_CLOEXEC" : C_Fd.t;
+val CLOEXEC = _const "Posix_IO_FD_CLOEXEC" : C_Int.t;
end
structure FLock =
struct
Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/prim1.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/prim1.sml 2006-04-30 14:07:24 UTC (rev 4424)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/prim1.sml 2006-04-30 18:58:08 UTC (rev 4425)
@@ -33,6 +33,7 @@
val debug = _command_line_const "MLton.debug": bool = false;
val detectOverflow = _command_line_const "MLton.detectOverflow": bool = true;
val safe = _command_line_const "MLton.safe": bool = true;
+ val bufSize = _command_line_const "TextIO.bufSize": Int32.int = 4096;
end
structure Exn =
Modified: mlton/branches/on-20050822-x86_64-branch/runtime/Posix/IO/fcntl-consts.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/Posix/IO/fcntl-consts.c 2006-04-30 14:07:24 UTC (rev 4424)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/Posix/IO/fcntl-consts.c 2006-04-30 18:58:08 UTC (rev 4425)
@@ -8,6 +8,6 @@
const C_Int_t Posix_IO_F_SETFL = F_SETFL;
const C_Int_t Posix_IO_F_SETOWN = F_SETOWN;
-const C_Fd_t Posix_IO_FD_CLOEXEC = FD_CLOEXEC;
+const C_Int_t Posix_IO_FD_CLOEXEC = FD_CLOEXEC;
const C_Int_t Posix_IO_O_ACCMODE = O_ACCMODE;
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-04-30 14:07:24 UTC (rev 4424)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gen/basis-ffi.def 2006-04-30 18:58:08 UTC (rev 4425)
@@ -368,7 +368,7 @@
Posix.FileSys.truncate = _import : NullString8.t * C_Off.t -> C_Int.t C_Errno.t
Posix.FileSys.umask = _import : C_Mode.t -> C_Mode.t
Posix.FileSys.unlink = _import : NullString8.t -> C_Int.t C_Errno.t
-Posix.IO.FD.CLOEXEC = _const : C_Fd.t
+Posix.IO.FD.CLOEXEC = _const : C_Int.t
Posix.IO.FLock.F_GETLK = _const : C_Int.t
Posix.IO.FLock.F_RDLCK = _const : C_Short.t
Posix.IO.FLock.F_SETLK = _const : C_Int.t