[MLton-commit] r6545
Matthew Fluet
fluet at mlton.org
Mon Apr 7 11:33:36 PDT 2008
Abstract Posix.Signal.signal with MkAbsRepEq.
----------------------------------------------------------------------
U mlton/trunk/basis-library/mlton/process.sml
U mlton/trunk/basis-library/mlton/signal.sml
U mlton/trunk/basis-library/posix/process.sml
U mlton/trunk/basis-library/posix/signal.sig
U mlton/trunk/basis-library/posix/signal.sml
----------------------------------------------------------------------
Modified: mlton/trunk/basis-library/mlton/process.sml
===================================================================
--- mlton/trunk/basis-library/mlton/process.sml 2008-04-07 18:33:32 UTC (rev 6544)
+++ mlton/trunk/basis-library/mlton/process.sml 2008-04-07 18:33:34 UTC (rev 6545)
@@ -214,12 +214,13 @@
case !status of
NONE =>
let
+ val signal' = PosixSignal.toRep signal
val () =
if useWindowsProcess
then
SysCall.simple
(fn () =>
- PrimitiveFFI.Windows.Process.terminate (pid, signal))
+ PrimitiveFFI.Windows.Process.terminate (pid, signal'))
else Process.kill (Process.K_PROC pid, signal)
in
ignore (reap p)
Modified: mlton/trunk/basis-library/mlton/signal.sml
===================================================================
--- mlton/trunk/basis-library/mlton/signal.sml 2008-04-07 18:33:32 UTC (rev 6544)
+++ mlton/trunk/basis-library/mlton/signal.sml 2008-04-07 18:33:34 UTC (rev 6545)
@@ -31,7 +31,7 @@
(C_Int.toInt Prim.NSIG, fn i =>
SysCall.syscallErr
({clear = false, restart = false, errVal = C_Int.fromInt ~1}, fn () =>
- {return = Prim.sigismember (fromInt i),
+ {return = Prim.sigismember (repFromInt i),
post = fn _ => true,
handlers = [(Error.inval, fn () => false)]}))
@@ -54,9 +54,10 @@
if b
then let
val s = fromInt i
+ val s' = repFromInt i
val res =
SysCall.simpleResult
- (fn () => Prim.sigismember s)
+ (fn () => Prim.sigismember s')
in
if res = C_Int.fromInt 1
then s::sigs
@@ -70,10 +71,14 @@
case m of
AllBut signals =>
(SysCall.simple Prim.sigfillset
- ; List.app (fn s => SysCall.simple (fn () => Prim.sigdelset s)) signals)
+ ; List.app (fn s => SysCall.simple
+ (fn () => Prim.sigdelset (toRep s)))
+ signals)
| Some signals =>
(SysCall.simple Prim.sigemptyset
- ; List.app (fn s => SysCall.simple (fn () => Prim.sigaddset s)) signals)
+ ; List.app (fn s => SysCall.simple
+ (fn () => Prim.sigaddset (toRep s)))
+ signals)
local
fun make (how: how) (m: t) =
@@ -114,7 +119,7 @@
fun initHandler (s: signal): Handler.t =
SysCall.syscallErr
({clear = false, restart = false, errVal = C_Int.fromInt ~1}, fn () =>
- {return = Prim.isDefault (s, r),
+ {return = Prim.isDefault (toRep s, r),
post = fn _ => if !r <> C_Int.zero then Default else Ignore,
handlers = [(Error.inval, fn () => InvalidSignal)]})
end
@@ -194,7 +199,7 @@
(fn (s, h, fs) =>
case h of
Handler f =>
- if Prim.isPending (fromInt s) <> C_Int.zero
+ if Prim.isPending (repFromInt s) <> C_Int.zero
then f::fs
else fs
| _ => fs) fs handlers
@@ -217,16 +222,16 @@
| (Default, Default) => ()
| (_, Default) =>
(setHandler (s, Default)
- ; SysCall.simpleRestart (fn () => Prim.default s))
+ ; SysCall.simpleRestart (fn () => Prim.default (toRep s)))
| (Handler _, Handler _) =>
setHandler (s, h)
| (_, Handler _) =>
(setHandler (s, h)
- ; SysCall.simpleRestart (fn () => Prim.handlee s))
+ ; SysCall.simpleRestart (fn () => Prim.handlee (toRep s)))
| (Ignore, Ignore) => ()
| (_, Ignore) =>
(setHandler (s, Ignore)
- ; SysCall.simpleRestart (fn () => Prim.ignore s))
+ ; SysCall.simpleRestart (fn () => Prim.ignore (toRep s)))
fun suspend m =
(Mask.write m
Modified: mlton/trunk/basis-library/posix/process.sml
===================================================================
--- mlton/trunk/basis-library/posix/process.sml 2008-04-07 18:33:32 UTC (rev 6544)
+++ mlton/trunk/basis-library/posix/process.sml 2008-04-07 18:33:34 UTC (rev 6545)
@@ -78,9 +78,9 @@
0 => W_EXITED
| n => W_EXITSTATUS (Word8.castFromSysWord (C_Int.castToSysWord n)))
else if Prim.ifSignaled status <> C_Int.zero
- then W_SIGNALED (Prim.termSig status)
+ then W_SIGNALED (PosixSignal.fromRep (Prim.termSig status))
else if Prim.ifStopped status <> C_Int.zero
- then W_STOPPED (Prim.stopSig status)
+ then W_STOPPED (PosixSignal.fromRep (Prim.stopSig status))
else raise Fail "Posix.Process.fromStatus"
fun fromStatus status =
fromStatus' (PreOS.Status.toRep status)
@@ -160,6 +160,7 @@
K_PROC pid => pid
| K_SAME_GROUP => C_PId.castFromFixedInt ~1
| K_GROUP pid => C_PId.~ pid
+ val s = PosixSignal.toRep s
in
SysCall.simple (fn () => Prim.kill (pid, s))
end
Modified: mlton/trunk/basis-library/posix/signal.sig
===================================================================
--- mlton/trunk/basis-library/posix/signal.sig 2008-04-07 18:33:32 UTC (rev 6544)
+++ mlton/trunk/basis-library/posix/signal.sig 2008-04-07 18:33:34 UTC (rev 6545)
@@ -34,6 +34,12 @@
val prof: signal
val vtalrm: signal
+ val fromRep: C_Int.t -> signal
+ val toRep: signal -> C_Int.t
+
+ val repFromInt: int -> C_Int.t
+ val repToInt: C_Int.t -> int
+
val fromInt: int -> signal
val toInt: signal -> int
end
Modified: mlton/trunk/basis-library/posix/signal.sml
===================================================================
--- mlton/trunk/basis-library/posix/signal.sml 2008-04-07 18:33:32 UTC (rev 6544)
+++ mlton/trunk/basis-library/posix/signal.sml 2008-04-07 18:33:34 UTC (rev 6545)
@@ -9,41 +9,51 @@
structure PosixSignal: POSIX_SIGNAL_EXTRA =
struct
open PrimitiveFFI.Posix.Signal
+ structure Signal = PrePosix.Signal
- type signal = C_Int.t
+ type signal = Signal.t
- val abrt = SIGABRT
- val alrm = SIGALRM
- val bus = SIGBUS
- val chld = SIGCHLD
- val cont = SIGCONT
- val fpe = SIGFPE
- val hup = SIGHUP
- val ill = SIGILL
- val int = SIGINT
- val kill = SIGKILL
- val pipe = SIGPIPE
- val poll = SIGPOLL
- val prof = SIGPROF
- val quit = SIGQUIT
- val segv = SIGSEGV
- val stop = SIGSTOP
- val sys = SIGSYS
- val term = SIGTERM
- val trap = SIGTRAP
- val tstp = SIGTSTP
- val ttin = SIGTTIN
- val ttou = SIGTTOU
- val urg = SIGURG
- val usr1 = SIGUSR1
- val usr2 = SIGUSR2
- val vtalrm = SIGVTALRM
- val xcpu = SIGXCPU
- val xfsz = SIGXFSZ
+ val abrt = Signal.fromRep SIGABRT
+ val alrm = Signal.fromRep SIGALRM
+ val bus = Signal.fromRep SIGBUS
+ val chld = Signal.fromRep SIGCHLD
+ val cont = Signal.fromRep SIGCONT
+ val fpe = Signal.fromRep SIGFPE
+ val hup = Signal.fromRep SIGHUP
+ val ill = Signal.fromRep SIGILL
+ val int = Signal.fromRep SIGINT
+ val kill = Signal.fromRep SIGKILL
+ val pipe = Signal.fromRep SIGPIPE
+ val poll = Signal.fromRep SIGPOLL
+ val prof = Signal.fromRep SIGPROF
+ val quit = Signal.fromRep SIGQUIT
+ val segv = Signal.fromRep SIGSEGV
+ val stop = Signal.fromRep SIGSTOP
+ val sys = Signal.fromRep SIGSYS
+ val term = Signal.fromRep SIGTERM
+ val trap = Signal.fromRep SIGTRAP
+ val tstp = Signal.fromRep SIGTSTP
+ val ttin = Signal.fromRep SIGTTIN
+ val ttou = Signal.fromRep SIGTTOU
+ val urg = Signal.fromRep SIGURG
+ val usr1 = Signal.fromRep SIGUSR1
+ val usr2 = Signal.fromRep SIGUSR2
+ val vtalrm = Signal.fromRep SIGVTALRM
+ val xcpu = Signal.fromRep SIGXCPU
+ val xfsz = Signal.fromRep SIGXFSZ
- val toInt = C_Int.toInt
- val fromInt = C_Int.fromInt
+ val fromRep = Signal.fromRep
+ val toRep = Signal.toRep
- val toWord = SysWord.fromInt o toInt
- val fromWord = fromInt o SysWord.toInt
+ val repToInt = C_Int.toInt
+ val repFromInt = C_Int.fromInt
+
+ val toInt = repToInt o toRep
+ val fromInt = fromRep o repFromInt
+
+ val repToWord = C_Int.castToSysWord
+ val repFromWord = C_Int.castFromSysWord
+
+ val toWord = repToWord o toRep
+ val fromWord = fromRep o repFromWord
end
More information about the MLton-commit
mailing list