1structure MLSYSPortable = 2struct 3 4exception Interrupt = General.Interrupt 5 6val listDir = Mosml.listDir 7 8(*--------------------------------------------------------------------------- 9 Efficiency hack. 10 ---------------------------------------------------------------------------*) 11 12local val cast : 'a -> int = Obj.magic 13in 14fun pointer_eq (x:'a, y:'a) = (cast x = cast y) 15fun ref_to_int (r : 'a ref) = cast r 16end; 17 18local 19 (* magic to ensure that interruptions (SIGINTs) are actually seen by the 20 linked executable as Interrupt exceptions *) 21prim_val catch_interrupt : bool -> unit = 1 "sys_catch_break"; 22in 23 24fun catch_SIGINT () = ignore (catch_interrupt true) 25 26val md5sum = Mosml.md5sum 27val time = Mosml.time 28 29end 30 31structure HOLSusp = Susp 32 33fun reraise e = raise e 34 35fun make_counter {inc,init} = 36 let 37 val n = ref init 38 in 39 fn () => !n before n := !n + inc 40 end 41 42fun syncref init = 43 let 44 val r = ref init 45 in 46 { get = fn() => !r, 47 upd = fn f => let val (res,nv) = f (!r) in r := nv; res end 48 } 49 end 50 51end (* struct *) 52