Import Upstream version 20180207
[hcoop/debian/mlton.git] / basis-library / mlton / mlton.sml
CommitLineData
7f918cf1
CE
1(* Copyright (C) 2010,2013,2016-2017 Matthew Fluet.
2 * Copyright (C) 1999-2008 Henry Cejtin, Matthew Fluet, Suresh
3 * Jagannathan, and Stephen Weeks.
4 * Copyright (C) 1997-2000 NEC Research Institute.
5 *
6 * MLton is released under a BSD-style license.
7 * See the file MLton-LICENSE for details.
8 *)
9
10structure MLton: MLTON =
11struct
12
13val isMLton = true
14
15(* The ref stuff is so that the (de)serializer always deals with pointers
16 * to heap objects.
17 *)
18(* val serialize = fn x => serialize (ref x)
19 * val deserialize = fn x => !(deserialize x)
20 *)
21
22val share = Primitive.MLton.share
23
24structure GC = MLtonGC
25
26fun shareAll () =
27 (GC.setHashConsDuringGC true
28 ; GC.collect ())
29
30fun size x =
31 C_Size.toInt (Primitive.MLton.size x)
32
33(* fun cleanAtExit () = let open Cleaner in clean atExit end *)
34
35val debug = Primitive.Controls.debug
36val eq = Primitive.MLton.eq
37val equal = Primitive.MLton.equal
38val hash = Primitive.MLton.hash
39(* val errno = Primitive.errno *)
40val safe = Primitive.Controls.safe
41
42structure Array = Array
43structure BinIO = MLtonIO (BinIO)
44(*structure CallStack = MLtonCallStack*)
45structure CharArray = struct
46 open CharArray
47 type t = array
48end
49structure CharVector = struct
50 open CharVector
51 type t = vector
52end
53structure Cont = MLtonCont
54structure Exn = MLtonExn
55structure Finalizable = MLtonFinalizable
56structure IntInf =
57 struct
58 open IntInf
59 type t = int
60 end
61structure Itimer = MLtonItimer
62structure LargeReal =
63 struct
64 open LargeReal
65 type t = real
66 end
67structure LargeWord =
68 struct
69 open LargeWord
70 type t = word
71 end
72structure Platform = MLtonPlatform
73structure Pointer = MLtonPointer
74structure ProcEnv = MLtonProcEnv
75structure Process = MLtonProcess
76(* structure Ptrace = MLtonPtrace *)
77structure Profile = MLtonProfile
78structure Random = MLtonRandom
79structure Real =
80 struct
81 open Real
82 type t = real
83 end
84structure Real32 =
85 struct
86 open Real32
87 type t = real
88 open Primitive.PackReal32
89 end
90structure Real64 =
91 struct
92 open Real64
93 type t = real
94 open Primitive.PackReal64
95 end
96structure Rlimit = MLtonRlimit
97structure Rusage = MLtonRusage
98structure Signal = MLtonSignal
99structure Syslog = MLtonSyslog
100structure TextIO = MLtonIO (TextIO)
101structure Thread = MLtonThread
102structure Vector = Vector
103structure Weak = MLtonWeak
104structure World = MLtonWorld
105structure Word =
106 struct
107 open Word
108 type t = word
109 end
110structure Word8 =
111 struct
112 open Word8
113 type t = word
114 end
115structure Word16 =
116 struct
117 open Word16
118 type t = word
119 end
120structure Word32 =
121 struct
122 open Word32
123 type t = word
124 end
125structure Word64 =
126 struct
127 open Word64
128 type t = word
129 end
130structure Word8Array = struct
131 open Word8Array
132 type t = array
133end
134structure Word8Vector = struct
135 open Word8Vector
136 type t = vector
137end
138
139val _ =
140 (Primitive.TopLevel.setHandler MLtonExn.defaultTopLevelHandler
141 ; Primitive.TopLevel.setSuffix Exit.defaultTopLevelSuffix)
142end
143
144(* Patch OS.FileSys.tmpName to use mkstemp. *)
145structure OS =
146 struct
147 open OS
148
149 structure FileSys =
150 struct
151 open FileSys
152
153 fun tmpName () =
154 let
155 val (f, out) =
156 MLton.TextIO.mkstemp (MLton.TextIO.tempPrefix "file")
157 val _ = TextIO.closeOut out
158 in
159 f
160 end
161 end
162 end