[MLton] cvs commit: runtime code reorganization and initial MinGW port
Stephen Weeks
sweeks@mlton.org
Wed, 25 Aug 2004 10:51:22 -0700
sweeks 04/08/25 10:51:20
Modified: . Makefile
basis-library/misc primitive.sml
basis-library/mlton itimer.sml platform.sig platform.sml
process.sml rusage.sml thread.sig
basis-library/net unix-sock.sml
basis-library/posix error.sig error.sml file-sys.sml io.sml
proc-env.sml sys-db.sml tty.sml
basis-library/real real.fun
basis-library/system io.sml path.sml
bin mlton platform upgrade-basis
doc/user-guide credits.tex
include main.h x86-main.h
lib/mlton-stubs exn.sig mlton.sig mlton.sml platform.sig
signal.sig thread.sig thread.sml world.sig
mlton/codegen/x86-codegen x86-codegen.fun
x86-mlton-basic.fun x86.fun
mlton/control control.sig control.sml
mlton/elaborate elaborate-core.fun
mlton/main lookup-constant.fun main.fun
runtime Makefile gc.c gc.h types.h
runtime/Posix/FileSys Stat.c Utimbuf.c access.c chdir.c
chmod.c chown.c fchmod.c fchown.c fpathconf.c
ftruncate.c getcwd.c link.c mkdir.c mkfifo.c open.c
pathconf.c readlink.c rename.c rmdir.c symlink.c
umask.c unlink.c
runtime/Posix/IO FLock.c close.c dup.c dup2.c fcntl2.c
fcntl3.c fsync.c lseek.c pipe.c read.c write.c
runtime/Posix/ProcEnv Tms.c Uname.c environ.c getenv.c
getgroups.c getlogin.c getpgrp.c isatty.c setenv.c
sysconf.c ttyname.c
runtime/Posix/Process alarm.c exece.c execp.c exit.c
exitStatus.c fork.c ifExited.c ifSignaled.c
ifStopped.c kill.c pause.c sleep.c stopSig.c
termSig.c waitpid.c
runtime/Posix/SysDB Group.c Passwd.c
runtime/basis CommandLine.c Date.c Debug.c IEEEReal.c
IntInf.c Stdio.c Thread.c Time.c
runtime/basis/Array numElements.c
runtime/basis/Int Word.c Word8Array.c Word8Vector.c
runtime/basis/Itimer set.c
runtime/basis/MLton allocTooLarge.c bug.c errno.c exit.c
gcTime.c profile.c rlimit.c rusage.c size.c
spawne.c spawnp.c world.c
runtime/basis/Net Net.c NetHostDB.c NetProtDB.c NetServDB.c
runtime/basis/Net/Socket INetSock.c UnixSock.c
runtime/basis/OS/IO poll.c
runtime/basis/Real class.c frexp.c gdtoa.c modf.c
nextAfter.c real.c signBit.c strto.c
Added: runtime platform.c platform.h
runtime/Posix Error.c Signal.c TTY.c
runtime/Posix/FileSys Dirstream.c ST.c
runtime/Posix/ProcEnv ProcEnv.c
runtime/basis GC.c PackReal.c Ptrace.c
runtime/basis/Net/Socket Socket.c
runtime/platform cygwin.c cygwin.h freebsd.c freebsd.h
linux.c linux.h mingw.c mingw.h netbsd.c netbsd.h
openbsd.c openbsd.h ptrace.h setenv.h
showMem.linux.c showMem.win32.c solaris.c solaris.h
spawn.h ssmmap.c totalRam.sysconf.c
totalRam.sysctl.c
Removed: runtime IntInf.h basis-constants.h libmlton.c libmlton.h
mlton-basis.h mlton-posix.h my-lib.c my-lib.h
net-constants.h posix-constants.h
runtime/Posix/Error clearErrno.c getErrno.c strerror.c
runtime/Posix/FileSys/Dirstream closedir.c opendir.c
readdir.c rewinddir.c
runtime/Posix/FileSys/ST isBlk.c isChr.c isDir.c isFIFO.c
isLink.c isReg.c isSock.c
runtime/Posix/ProcEnv ctermid.c getegid.c geteuid.c getgid.c
getpid.c getppid.c getuid.c setgid.c setpgid.c
setsid.c setuid.c
runtime/Posix/Signal Signal.c isPending.c resetPending.c
runtime/Posix/TTY Termios.c drain.c flow.c flush.c getpgrp.c
sendbreak.c setpgrp.c
runtime/basis/GC setMessages.c setSummary.c
runtime/basis/Net/Socket Ctl.c accept.c bind.c close.c
connect.c familyOfAddr.c listen.c recv.c recvFrom.c
send.c sendTo.c shutdown.c socket.c socketPair.c
runtime/basis/PackReal subVec.c update.c
runtime/basis/Ptrace ptrace2.c ptrace4.c
Log:
MAIL runtime code reorganization and initial MinGW port
Reorganized the runtime to improve portability. Now, there is a
single include file, platform.h, which all runtime C files include,
that is responsible for making the platforms present a consistent
interface. Platform-specific code goes in
runtime/platform/<os>.{c,h}. There are a few remaining
platform-specific #if's in gc.c. Using platform.h greatly simplifies
porting to a new platform, because we don't have to spray #if's over
lots of files (as was starting to happen with MinGW) and we don't have
to duplicate knowledge about what include files are needed.
Used platform.h to define various properties (HAS_MREMAP, HAS_WEAK,
...) that can be tested for (mostly in gc.c) to decide whether and how
to implement certain things.
Got rid of the myriad of other include files (libmlton.h,
basis-constants.h, my-lib.h, posix-constants.h, etc.) used to build
the runtime. Instead, all these have been merged into platform.h, and
any associate code into platform.c.
Grouped some runtime functions together that had been in separate
files to keep executable sizes down. I did this for faster
compilation (things are slower now that every file includes the huge
platform.h), but kept executable size in mind and tried to only group
functions that were likely to be used together or were very small.
There is still some more room to shrink in this direction. As the
garbage collector has gotten bigger, the relative code-size savings
from having lots of files has gotten smaller.
Integrated Brent's patch to port MLton to MinGW. It has not been
tested yet on that platform, and it surely won't even compile, but I
did check to make sure I didn't break any of our old platforms.
Modified basis library to stub out functions that are not (yet)
implemented on MinGW.
Revision Changes Path
1.121 +1 -1 mlton/Makefile
Index: Makefile
===================================================================
RCS file: /cvsroot/mlton/mlton/Makefile,v
retrieving revision 1.120
retrieving revision 1.121
diff -u -r1.120 -r1.121
--- Makefile 25 Aug 2004 13:10:52 -0000 1.120
+++ Makefile 25 Aug 2004 17:51:05 -0000 1.121
@@ -213,7 +213,7 @@
@echo 'Compiling MLton runtime system for $(TARGET).'
$(MAKE) -C runtime
$(CP) $(RUN)/*.a $(LIB)/$(TARGET)/
- $(CP) runtime/*.h include/*.h $(LIB)/include/
+ $(CP) runtime/platform/ runtime/*.h include/*.h $(LIB)/include/
$(MAKE) -C bytecode
bytecode/print-opcodes >$(LIB)/opcodes
ar r $(LIB)/$(TARGET)/libmlton.a bytecode/interpret.o
1.116 +6 -3 mlton/basis-library/misc/primitive.sml
Index: primitive.sml
===================================================================
RCS file: /cvsroot/mlton/mlton/basis-library/misc/primitive.sml,v
retrieving revision 1.115
retrieving revision 1.116
diff -u -r1.115 -r1.116
--- primitive.sml 28 Jul 2004 21:05:08 -0000 1.115
+++ primitive.sml 25 Aug 2004 17:51:06 -0000 1.116
@@ -776,6 +776,7 @@
Cygwin
| FreeBSD
| Linux
+ | MinGW
| NetBSD
| OpenBSD
| Solaris
@@ -785,9 +786,10 @@
0 => Cygwin
| 1 => FreeBSD
| 2 => Linux
- | 3 => NetBSD
- | 4 => OpenBSD
- | 5 => Solaris
+ | 3 => MinGW
+ | 4 => NetBSD
+ | 5 => OpenBSD
+ | 6 => Solaris
| _ => raise Fail "strange MLton_Platform_OS_Host"
end
end
@@ -852,6 +854,7 @@
structure Rusage =
struct
val ru = _import "MLton_Rusage_ru": unit -> unit;
+
val self_utime_sec = _import "MLton_Rusage_self_utime_sec": unit -> int;
val self_utime_usec = _import "MLton_Rusage_self_utime_usec": unit -> int;
val self_stime_sec = _import "MLton_Rusage_self_stime_sec": unit -> int;
1.10 +3 -1 mlton/basis-library/mlton/itimer.sml
Index: itimer.sml
===================================================================
RCS file: /cvsroot/mlton/mlton/basis-library/mlton/itimer.sml,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- itimer.sml 11 Sep 2003 18:58:44 -0000 1.9
+++ itimer.sml 25 Aug 2004 17:51:06 -0000 1.10
@@ -27,7 +27,9 @@
in
Prim.set (toInt t, s1, u1, s2, u2)
end
-
+
+ val set' = PosixError.stubMinGW set'
+
fun set (z as (t, _)) =
if Primitive.MLton.Profile.isOn
andalso t = Prof
1.7 +8 -1 mlton/basis-library/mlton/platform.sig
Index: platform.sig
===================================================================
RCS file: /cvsroot/mlton/mlton/basis-library/mlton/platform.sig,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- platform.sig 13 Jun 2004 03:54:57 -0000 1.6
+++ platform.sig 25 Aug 2004 17:51:06 -0000 1.7
@@ -11,7 +11,14 @@
structure OS:
sig
- datatype t = Cygwin | FreeBSD | Linux | NetBSD | OpenBSD | Solaris
+ datatype t =
+ Cygwin
+ | FreeBSD
+ | Linux
+ | MinGW
+ | NetBSD
+ | OpenBSD
+ | Solaris
val fromString: string -> t option
val host: t
1.6 +1 -0 mlton/basis-library/mlton/platform.sml
Index: platform.sml
===================================================================
RCS file: /cvsroot/mlton/mlton/basis-library/mlton/platform.sml,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- platform.sml 13 Jun 2004 03:54:57 -0000 1.5
+++ platform.sml 25 Aug 2004 17:51:06 -0000 1.6
@@ -28,6 +28,7 @@
val all = [(Cygwin, "Cygwin"),
(FreeBSD, "FreeBSD"),
(Linux, "Linux"),
+ (MinGW, "MinGW"),
(NetBSD, "NetBSD"),
(OpenBSD, "OpenBSD"),
(Solaris, "Solaris")]
1.14 +11 -3 mlton/basis-library/mlton/process.sml
Index: process.sml
===================================================================
RCS file: /cvsroot/mlton/mlton/basis-library/mlton/process.sml,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- process.sml 1 May 2004 20:11:39 -0000 1.13
+++ process.sml 25 Aug 2004 17:51:06 -0000 1.14
@@ -8,10 +8,18 @@
type pid = Pid.t
- val isCygwin = let open MLton.Platform.OS in host = Cygwin end
+ val useSpawn =
+ let
+ open MLton.Platform.OS
+ in
+ case host of
+ Cygwin => true
+ | MinGW => true
+ | _ => false
+ end
fun spawne {path, args, env} =
- if isCygwin
+ if useSpawn
then
let
val path = NullString.nullTerm path
@@ -33,7 +41,7 @@
spawne {path = path, args = args, env = Posix.ProcEnv.environ ()}
fun spawnp {file, args} =
- if isCygwin
+ if useSpawn
then
let
val file = NullString.nullTerm file
1.4 +6 -3 mlton/basis-library/mlton/rusage.sml
Index: rusage.sml
===================================================================
RCS file: /cvsroot/mlton/mlton/basis-library/mlton/rusage.sml,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- rusage.sml 10 Feb 2004 03:21:41 -0000 1.3
+++ rusage.sml 25 Aug 2004 17:51:06 -0000 1.4
@@ -1,6 +1,6 @@
structure MLtonRusage: MLTON_RUSAGE =
struct
- open Primitive.MLton.Rusage
+ structure Prim = Primitive.MLton.Rusage
type t = {utime: Time.time, stime: Time.time}
@@ -21,8 +21,9 @@
end
fun rusage () =
- let
- val _ = ru ()
+ let
+ val () = Prim.ru ()
+ open Prim
in
{children = collect (children_utime_sec, children_utime_usec,
children_stime_sec, children_stime_usec),
@@ -31,4 +32,6 @@
self = collect (self_utime_sec, self_utime_usec,
self_stime_sec, self_stime_usec)}
end
+
+ val rusage = PosixError.stubMinGW rusage
end
1.14 +3 -0 mlton/basis-library/mlton/thread.sig
Index: thread.sig
===================================================================
RCS file: /cvsroot/mlton/mlton/basis-library/mlton/thread.sig,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- thread.sig 24 Aug 2004 23:49:29 -0000 1.13
+++ thread.sig 25 Aug 2004 17:51:06 -0000 1.14
@@ -4,6 +4,9 @@
* MLton is released under the GNU General Public License (GPL).
* Please see the file MLton-LICENSE for license information.
*)
+
+type int = Int.int
+
signature MLTON_THREAD =
sig
structure AtomicState :
1.9 +6 -0 mlton/basis-library/net/unix-sock.sml
Index: unix-sock.sml
===================================================================
RCS file: /cvsroot/mlton/mlton/basis-library/net/unix-sock.sml,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- unix-sock.sml 20 Feb 2004 19:17:32 -0000 1.8
+++ unix-sock.sml 25 Aug 2004 17:51:06 -0000 1.9
@@ -16,6 +16,7 @@
in
finish ()
end
+
fun fromAddr sa =
let
val sa = Socket.unpackSockAddr sa
@@ -26,6 +27,11 @@
in
CharArraySlice.vector (CharArraySlice.slice (a, 0, SOME len))
end
+
+ val stub = PosixError.stubMinGW
+
+ val toAddr = stub toAddr
+ val fromAddr = stub fromAddr
structure Strm =
struct
1.7 +1 -0 mlton/basis-library/posix/error.sig
Index: error.sig
===================================================================
RCS file: /cvsroot/mlton/mlton/basis-library/posix/error.sig,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- error.sig 18 May 2004 00:35:40 -0000 1.6
+++ error.sig 25 Aug 2004 17:51:06 -0000 1.7
@@ -63,6 +63,7 @@
val cleared: syserror
val raiseSys: syserror -> 'a
+ val stubMinGW: ('a -> 'b) -> 'a -> 'b
structure SysCall :
sig
1.13 +8 -0 mlton/basis-library/posix/error.sml
Index: error.sml
===================================================================
RCS file: /cvsroot/mlton/mlton/basis-library/posix/error.sml,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- error.sml 1 Jul 2004 17:26:01 -0000 1.12
+++ error.sml 25 Aug 2004 17:51:06 -0000 1.13
@@ -49,6 +49,14 @@
fun raiseSys n = raise SysErr (errorMsg n, SOME n)
+ val stubMinGW: ('a -> 'b) -> ('a -> 'b) =
+ fn f =>
+ if let open Primitive.MLton.Platform.OS
+ in MinGW = host
+ end
+ then fn _ => raiseSys nosys
+ else f
+
structure SysCall =
struct
structure Thread = Primitive.Thread
1.19 +17 -3 mlton/basis-library/posix/file-sys.sml
Index: file-sys.sml
===================================================================
RCS file: /cvsroot/mlton/mlton/basis-library/posix/file-sys.sml,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- file-sys.sml 7 Jul 2004 18:36:02 -0000 1.18
+++ file-sys.sml 25 Aug 2004 17:51:06 -0000 1.19
@@ -202,6 +202,7 @@
val umask = Prim.umask
+
local
fun wrap p arg = (SysCall.simple (fn () => p arg); ())
fun wrapRestart p arg = (SysCall.simpleRestart (fn () => p arg); ())
@@ -218,7 +219,8 @@
val symlink = wrapOldNew Prim.symlink
val chmod = wrap (fn (p, m) => Prim.chmod (NullString.nullTerm p, m))
val fchmod = wrap (fn (FD n, m) => Prim.fchmod (n, m))
- val chown = wrap (fn (s, u, g) => Prim.chown (NullString.nullTerm s, u, g))
+ val chown =
+ wrap (fn (s, u, g) => Prim.chown (NullString.nullTerm s, u, g))
val fchown = wrap (fn (FD n, u, g) => Prim.fchown (n, u, g))
val ftruncate = wrapRestart (fn (FD n, pos) => Prim.ftruncate (n, pos))
end
@@ -387,8 +389,20 @@
handlers = [(Error.cleared, fn () => NONE)]}
end)
in
- val pathconf = make (fn (path, s) =>
- Prim.pathconf (NullString.nullTerm path, s))
+ val pathconf =
+ make (fn (path, s) => Prim.pathconf (NullString.nullTerm path, s))
val fpathconf = make (fn (FD n, s) => Prim.fpathconf (n, s))
end
+
+ val stub = Error.stubMinGW
+
+ val chown = stub chown
+ val fchown = stub fchown
+ val fpathconf = stub fpathconf
+ val ftruncate = stub ftruncate
+ val link = stub link
+ val mkfifo = stub mkfifo
+ val pathconf = stub pathconf
+ val readlink = stub readlink
+ val symlink = stub symlink
end
1.17 +10 -0 mlton/basis-library/posix/io.sml
Index: io.sml
===================================================================
RCS file: /cvsroot/mlton/mlton/basis-library/posix/io.sml,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- io.sml 1 May 2004 20:11:39 -0000 1.16
+++ io.sml 25 Aug 2004 17:51:06 -0000 1.17
@@ -374,4 +374,14 @@
val {mkReader = mkTextReader, mkWriter = mkTextWriter} =
make rwChar (TextPrimIO.RD, TextPrimIO.WR)
end
+
+ val stub = PosixError.stubMinGW
+ val dupfd = stub dupfd
+ val fsync = stub fsync
+ val getfd = stub getfd
+ val getlk = stub getlk
+ val pipe = stub pipe
+ val setfd = stub setfd
+ val setlk = stub setlk
+ val setlkw = stub setlkw
end
1.11 +20 -0 mlton/basis-library/posix/proc-env.sml
Index: proc-env.sml
===================================================================
RCS file: /cvsroot/mlton/mlton/basis-library/posix/proc-env.sml,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- proc-env.sml 1 May 2004 20:11:39 -0000 1.10
+++ proc-env.sml 25 Aug 2004 17:51:06 -0000 1.11
@@ -141,4 +141,24 @@
(if Primitive.Pointer.isNull cs then ~1 else 0,
fn () => CS.toString cs)
end)
+
+ val stub = Error.stubMinGW
+ val ctermid = stub ctermid
+ val getegid = stub getegid
+ val geteuid = stub geteuid
+ val getgid = stub getgid
+ val getgroups = stub getgroups
+ val getlogin = stub getlogin
+ val getpgrp = stub getpgrp
+ val getpid = stub getpid
+ val getppid = stub getppid
+ val getuid = stub getuid
+ val setgid = stub setgid
+ val setpgid = stub setpgid
+ val setsid = stub setsid
+ val setuid = stub setuid
+ val sysconf = stub sysconf
+ val times = stub times
+ val ttyname = stub ttyname
+ val uname = stub uname
end
1.5 +9 -1 mlton/basis-library/posix/sys-db.sml
Index: sys-db.sml
===================================================================
RCS file: /cvsroot/mlton/mlton/basis-library/posix/sys-db.sml,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- sys-db.sml 1 May 2004 20:11:39 -0000 1.4
+++ sys-db.sml 25 Aug 2004 17:51:06 -0000 1.5
@@ -12,6 +12,8 @@
structure Error = PosixError
structure SysCall = Error.SysCall
+ val stub = Error.stubMinGW
+
type uid = Prim.uid
type gid = Prim.gid
@@ -48,8 +50,9 @@
let val name = NullString.nullTerm name
in Passwd.fromC (fn () => Prim.getpwnam name)
end
+
fun getpwuid uid = Passwd.fromC (fn () => Prim.getpwuid uid)
-
+
structure Group =
struct
type group = {name: string,
@@ -75,5 +78,10 @@
let val name = NullString.nullTerm name
in Group.fromC (fn () => Prim.getgrnam name)
end
+
fun getgrgid gid = Group.fromC (fn () => Prim.getgrgid gid)
+
+ val getgrgid = stub getgrgid
+ val getgrnam = stub getgrnam
+ val getpwuid = stub getpwuid
end
1.8 +11 -1 mlton/basis-library/posix/tty.sml
Index: tty.sml
===================================================================
RCS file: /cvsroot/mlton/mlton/basis-library/posix/tty.sml,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- tty.sml 1 May 2004 20:11:39 -0000 1.7
+++ tty.sml 25 Aug 2004 17:51:06 -0000 1.8
@@ -131,7 +131,7 @@
cc = Cstring.toCharArrayOfLength (Termios.cc (), V.nccs),
ispeed = Termios.ispeed (),
ospeed = Termios.ospeed ()}))
-
+
fun setattr (FD fd, a, {iflag, oflag, cflag, lflag, cc, ispeed, ospeed}) =
SysCall.syscallRestart
(fn () =>
@@ -168,5 +168,15 @@
fun setpgrp (FD fd, pid) =
SysCall.simpleRestart (fn () => Prim.setpgrp (fd, pid))
+
+ val stub = Error.stubMinGW
+ val drain = stub drain
+ val flow = stub flow
+ val flush = stub flush
+ val getattr = stub getattr
+ val getpgrp = stub getpgrp
+ val sendbreak = stub sendbreak
+ val setattr = stub setattr
+ val setpgrp = stub setpgrp
end
end
1.25 +25 -34 mlton/basis-library/real/real.fun
Index: real.fun
===================================================================
RCS file: /cvsroot/mlton/mlton/basis-library/real/real.fun,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- real.fun 14 Jun 2004 07:49:05 -0000 1.24
+++ real.fun 25 Aug 2004 17:51:07 -0000 1.25
@@ -633,34 +633,26 @@
struct
open Prim.Math
- (* Patches for Cygwin and Solaris, whose math libraries do not handle
- * out-of-range args.
+ (* Patch functions to handle out-of-range args. Many C math
+ * libraries do not do what the SML Basis Spec requires.
*)
- val (acos, asin, ln, log10) =
- if not MLton.native
- andalso let
- open MLton.Platform.OS
- in
- case host of
- Cygwin => true
- | Solaris => true
- | _ => false
- end
- then
- let
- fun patch f x =
- if x < ~one orelse x > one
- then nan
- else f x
- val acos = patch acos
- val asin = patch asin
- fun patch f x = if x < zero then nan else f x
- val ln = patch ln
- val log10 = patch log10
- in
- (acos, asin, ln, log10)
- end
- else (acos, asin, ln, log10)
+
+ local
+ fun patch f x =
+ if x < ~one orelse x > one
+ then nan
+ else f x
+ in
+ val acos = patch acos
+ val asin = patch asin
+ end
+
+ local
+ fun patch f x = if x < zero then nan else f x
+ in
+ val ln = patch ln
+ val log10 = patch log10
+ end
(* The x86 doesn't get exp right on infs. *)
val exp =
@@ -678,8 +670,8 @@
* The Linux math library doesn't get pow (x, y) right when x < 0
* and y is large (but finite).
*
- * So, we define a safePow function that gives the correct result
- * on exceptional cases, and only calls pow with x > 0.
+ * So, we define a pow function that gives the correct result on
+ * exceptional cases, and only calls the C pow with x > 0.
*)
fun isInt (x: real): bool = x == realFloor x
@@ -690,7 +682,7 @@
fun isNeg x = x < zero
- fun safePow (x, y) =
+ fun pow (x, y) =
case class y of
INF =>
if class x = NAN
@@ -729,11 +721,10 @@
if isNeg x
then if isInt y
then if isEven y
- then pow (~ x, y)
- else negOne * pow (~ x, y)
+ then Prim.Math.pow (~ x, y)
+ else negOne * Prim.Math.pow (~ x, y)
else nan
- else pow (x, y))
- val pow = safePow
+ else Prim.Math.pow (x, y))
fun cosh x =
case class x of
1.10 +2 -0 mlton/basis-library/system/io.sml
Index: io.sml
===================================================================
RCS file: /cvsroot/mlton/mlton/basis-library/system/io.sml,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- io.sml 7 Jul 2004 18:36:03 -0000 1.9
+++ io.sml 25 Aug 2004 17:51:07 -0000 1.10
@@ -137,6 +137,8 @@
end
end (* local *)
+ val poll = PosixError.stubMinGW poll
+
(* check for conditions *)
fun isIn (PollInfo(_, flgs)) = #rd flgs
fun isOut (PollInfo(_, flgs)) = #wr flgs
1.8 +15 -5 mlton/basis-library/system/path.sml
Index: path.sml
===================================================================
RCS file: /cvsroot/mlton/mlton/basis-library/system/path.sml,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- path.sml 16 Feb 2004 22:43:23 -0000 1.7
+++ path.sml 25 Aug 2004 17:51:07 -0000 1.8
@@ -30,13 +30,23 @@
val volslash = "/"
fun isslash c = c = #"/"
fun validVol s = s = ""
+ fun iscolon c = c = #":"
- fun splitabsvolrest s =
- if size s >= 1 andalso isslash (s sub 0) then
- (true, "", substring(s, 1, NONE))
- else
- (false, "", s);
+ val isMinGW = let open Primitive.MLton.Platform.OS in host = MinGW end
+ fun splitabsvolrest s =
+ if isMinGW
+ then
+ (* Handle the "C:\" case *)
+ if size s >= 3 andalso iscolon (s sub 1)
+ then (true, "", substring(s, 3, NONE))
+ else (false, "", s)
+ else
+ if size s >= 1 andalso isslash (s sub 0) then
+ (true, "", substring(s, 1, NONE))
+ else
+ (false, "", s);
+
in
val parentArc = ".."
1.35 +1 -0 mlton/bin/mlton
Index: mlton
===================================================================
RCS file: /cvsroot/mlton/mlton/bin/mlton,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- mlton 20 Aug 2004 16:33:30 -0000 1.34
+++ mlton 25 Aug 2004 17:51:07 -0000 1.35
@@ -71,6 +71,7 @@
-mcpu=ultrasparc' \
-target-link-opt cygwin '-lgmp' \
-target-link-opt freebsd '-L/usr/local/lib/ -lgmp' \
+ -target-link-opt mingw '-lgmp -lws2_32 -lkernel32' \
-target-link-opt netbsd \
'-Wl,-R/usr/pkg/lib -L/usr/local/lib/ -lgmp' \
-target-link-opt openbsd '-L/usr/local/lib/ -lgmp' \
1.4 +3 -0 mlton/bin/platform
Index: platform
===================================================================
RCS file: /cvsroot/mlton/mlton/bin/platform,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- platform 13 Jun 2004 03:54:57 -0000 1.3
+++ platform 25 Aug 2004 17:51:07 -0000 1.4
@@ -35,6 +35,9 @@
FreeBSD*)
HOST_OS='freebsd'
;;
+MINGW*)
+ HOST_OS='mingw'
+;;
NetBSD*)
HOST_OS='netbsd'
;;
1.11 +6 -1 mlton/bin/upgrade-basis
Index: upgrade-basis
===================================================================
RCS file: /cvsroot/mlton/mlton/bin/upgrade-basis,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- upgrade-basis 30 Jul 2004 19:05:48 -0000 1.10
+++ upgrade-basis 25 Aug 2004 17:51:07 -0000 1.11
@@ -110,6 +110,9 @@
linux)
os='Linux'
;;
+mingw)
+ os='MinGW'
+;;
netbsd)
os='NetBSD'
;;
@@ -155,11 +158,13 @@
structure OS =
struct
- datatype t = Cygwin | FreeBSD | Linux | NetBSD | OpenBSD | Solaris
+ datatype t = Cygwin | FreeBSD | Linux | MinGW | NetBSD
+ | OpenBSD | Solaris
val all = [(Cygwin, "Cygwin"),
(FreeBSD, "FreeBSD"),
(Linux, "Linux"),
+ (MinGW, "MinGW"),
(NetBSD, "NetBSD"),
(OpenBSD, "OpenBSD"),
(Solaris, "Solaris")]
1.38 +3 -0 mlton/doc/user-guide/credits.tex
Index: credits.tex
===================================================================
RCS file: /cvsroot/mlton/mlton/doc/user-guide/credits.tex,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -r1.37 -r1.38
--- credits.tex 28 Jul 2004 21:05:09 -0000 1.37
+++ credits.tex 25 Aug 2004 17:51:07 -0000 1.38
@@ -52,6 +52,9 @@
development of MLBs.
\item
+Brent Fulgham ported {\mlton} to MinGW.
+
+\item
Simon Helsen (\mailto{shelsen}{acm.org}) has provided bug reports, suggestions,
and helpful discussions.
1.9 +1 -1 mlton/include/main.h
Index: main.h
===================================================================
RCS file: /cvsroot/mlton/mlton/include/main.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- main.h 13 May 2004 16:38:37 -0000 1.8
+++ main.h 25 Aug 2004 17:51:07 -0000 1.9
@@ -1,7 +1,7 @@
#ifndef _MAIN_H_
#define _MAIN_H_
-#include "libmlton.h"
+#include "platform.h"
/* The label must be declared as weak because gcc's optimizer may prove that
* the code that declares the label is dead and hence eliminate the declaration.
1.15 +20 -20 mlton/include/x86-main.h
Index: x86-main.h
===================================================================
RCS file: /cvsroot/mlton/mlton/include/x86-main.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- x86-main.h 13 Jun 2004 03:54:57 -0000 1.14
+++ x86-main.h 25 Aug 2004 17:51:07 -0000 1.15
@@ -4,20 +4,20 @@
#include "main.h"
/* Globals */
-word applyFFTemp;
-word checkTemp;
-word cReturnTemp[16];
-word c_stackP;
-word divTemp;
-word eq1Temp;
-word eq2Temp;
-word fileTemp;
-word fildTemp;
-word fpswTemp;
-word indexTemp;
-word intInfTemp;
+Word applyFFTemp;
+Word checkTemp;
+Word cReturnTemp[16];
+Word c_stackP;
+Word divTemp;
+Word eq1Temp;
+Word eq2Temp;
+Word fileTemp;
+Word fildTemp;
+Word fpswTemp;
+Word indexTemp;
+Word intInfTemp;
char MLton_bug_msg[] = "cps machine";
-word raTemp1;
+Word raTemp1;
double raTemp2;
double realTemp1D;
double realTemp2D;
@@ -25,17 +25,17 @@
float realTemp1S;
float realTemp2S;
float realTemp3S;
-word spill[16];
-word stackTopTemp;
-word statusTemp;
-word switchTemp;
-word threadTemp;
+Word spill[16];
+Word stackTopTemp;
+Word statusTemp;
+Word switchTemp;
+Word threadTemp;
#ifndef DEBUG_X86CODEGEN
#define DEBUG_X86CODEGEN FALSE
#endif
-#if (defined (__CYGWIN__))
+#if (defined (__CYGWIN__) || defined (__MSVCRT__))
#define ReturnToC "_Thread_returnToC"
#elif (defined (__FreeBSD__) || defined (__linux__) || defined (__NetBSD__) || defined (__OpenBSD__) || defined (__sun__))
#define ReturnToC "Thread_returnToC"
@@ -45,7 +45,7 @@
#define Main(al, cs, mg, mfs, mmc, pk, ps, ml, reserveEsp) \
void MLton_jumpToSML (pointer jump) { \
- word lc_stackP; \
+ Word lc_stackP; \
\
if (DEBUG_X86CODEGEN) \
fprintf (stderr, "MLton_jumpToSML(0x%08x) starting\n", (uint)jump); \
1.4 +1 -0 mlton/lib/mlton-stubs/exn.sig
Index: exn.sig
===================================================================
RCS file: /cvsroot/mlton/mlton/lib/mlton-stubs/exn.sig,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- exn.sig 28 Feb 2004 01:55:14 -0000 1.3
+++ exn.sig 25 Aug 2004 17:51:07 -0000 1.4
@@ -1,5 +1,6 @@
signature MLTON_EXN =
sig
+ val addExnMessager: (exn -> string option) -> unit
val history: exn -> string list
val topLevelHandler: exn -> 'a (* does not return *)
end
1.20 +1 -3 mlton/lib/mlton-stubs/mlton.sig
Index: mlton.sig
===================================================================
RCS file: /cvsroot/mlton/mlton/lib/mlton-stubs/mlton.sig,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- mlton.sig 28 Feb 2004 01:55:14 -0000 1.19
+++ mlton.sig 25 Aug 2004 17:51:07 -0000 1.20
@@ -5,9 +5,7 @@
* MLton is released under the GNU General Public License (GPL).
* Please see the file MLton-LICENSE for license information.
*)
-type int = Int.int
-type word = Word.word
-
+
signature MLTON =
sig
(* val cleanAtExit: unit -> unit *)
1.36 +13 -2 mlton/lib/mlton-stubs/mlton.sml
Index: mlton.sml
===================================================================
RCS file: /cvsroot/mlton/mlton/lib/mlton-stubs/mlton.sml,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- mlton.sml 11 Jul 2004 00:18:43 -0000 1.35
+++ mlton.sml 25 Aug 2004 17:51:07 -0000 1.36
@@ -32,6 +32,9 @@
*)
structure MLton: MLTON =
struct
+ type int = Int.int
+ type word = Word.word
+
type pointer = Word32.word
val cleanAtExit = fn _ => raise Fail "cleanAtExit"
@@ -92,6 +95,7 @@
struct
val history = fn _ => []
+ val addExnMessager = fn _ => raise Fail "Exn.addExnMessager"
val topLevelHandler = fn _ => raise Fail "Exn.topLevelHandler"
end
@@ -167,7 +171,14 @@
structure OS =
struct
- datatype t = Cygwin | FreeBSD | Linux | NetBSD | OpenBSD | Solaris
+ datatype t =
+ Cygwin
+ | FreeBSD
+ | Linux
+ | MinGW
+ | NetBSD
+ | OpenBSD
+ | Solaris
val host: t = Linux
@@ -305,7 +316,7 @@
structure Rusage =
struct
- type t = {utime: Time.time, stime: Time.time}
+ type t = {stime: Time.time, utime: Time.time}
(* Fake it with Posix.ProcEnv.times *)
fun rusage () =
1.7 +8 -1 mlton/lib/mlton-stubs/platform.sig
Index: platform.sig
===================================================================
RCS file: /cvsroot/mlton/mlton/lib/mlton-stubs/platform.sig,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- platform.sig 13 Jun 2004 03:54:58 -0000 1.6
+++ platform.sig 25 Aug 2004 17:51:07 -0000 1.7
@@ -11,7 +11,14 @@
structure OS:
sig
- datatype t = Cygwin | FreeBSD | Linux | NetBSD | OpenBSD | Solaris
+ datatype t =
+ Cygwin
+ | FreeBSD
+ | Linux
+ | MinGW
+ | NetBSD
+ | OpenBSD
+ | Solaris
val fromString: string -> t option
val host: t
1.11 +1 -1 mlton/lib/mlton-stubs/signal.sig
Index: signal.sig
===================================================================
RCS file: /cvsroot/mlton/mlton/lib/mlton-stubs/signal.sig,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- signal.sig 19 May 2004 00:22:36 -0000 1.10
+++ signal.sig 25 Aug 2004 17:51:07 -0000 1.11
@@ -8,7 +8,7 @@
type t
val default: t
- val handler: (unit MLtonThread.t -> unit MLtonThread.t) -> t
+ val handler: (MLtonThread.Runnable.t -> MLtonThread.Runnable.t) -> t
val ignore: t
val isDefault: t -> bool
val isIgnore: t -> bool
1.8 +37 -16 mlton/lib/mlton-stubs/thread.sig
Index: thread.sig
===================================================================
RCS file: /cvsroot/mlton/mlton/lib/mlton-stubs/thread.sig,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- thread.sig 14 Apr 2004 01:12:47 -0000 1.7
+++ thread.sig 25 Aug 2004 17:51:07 -0000 1.8
@@ -1,5 +1,12 @@
-type int = Int.int
+(* Copyright (C) 2004 Henry Cejtin, Matthew Fluet, Suresh
+ * Jagannathan, and Stephen Weeks.
+ *
+ * MLton is released under the GNU General Public License (GPL).
+ * Please see the file MLton-LICENSE for license information.
+ *)
+type int = Int.int
+
signature MLTON_THREAD =
sig
structure AtomicState :
@@ -11,29 +18,43 @@
val atomically: (unit -> 'a) -> 'a
val atomicState: unit -> AtomicState.t
+ structure Runnable :
+ sig
+ type t
+ end
+
type 'a t
- (* new f creates a new thread that will apply f to whatever is thrown
- * to the thread. f must terminate by throwing to another thread or
- * exiting the process.
+ (* new f
+ * create a new thread that, when run, applies f to
+ * the value given to the thread. f must terminate by
+ * <VALREF/switch/ing to another thread or exiting the process.
*)
val new: ('a -> unit) -> 'a t
(* prepend(t, f)
- * Create a new thread (destroying t in the process) that evaluates
- * f and passes the result to t.
+ * create a new thread (destroying t in the process) that first
+ * applies f to the value given to the thread and then continues
+ * with t. This is a constant time operation.
*)
val prepend: 'a t * ('b -> 'a) -> 'b t
- (* switch f = (t, x)
- * Applies f to the current thread, and then switches to t with
- * argument x. f runs in a critical section.
- * It is an error for f to call switch.
+ (* prepare(t, v)
+ * create a new runnable thread (destroying t in the process)
+ * that will evaluate t on v.
+ *)
+ val prepare: 'a t * 'a -> Runnable.t
+ (* switch f
+ * apply f to the current thread to get rt, and then start
+ * running thread rt. It is an error for f to
+ * perform another switch. f is guaranteed to run
+ * atomically.
*)
- val switch: ('a t -> 'b t * 'b) -> 'a
- (* switch' is a generalization of switch that evaluates the thunk
- * x in the context of t (i.e. t's stack and exception handlers are in
- * place).
+ val switch: ('a t -> Runnable.t) -> 'a
+ (* atomicSwitch f
+ * as switch, but assumes an atomic calling context. Upon
+ * switch-ing back to the current thread, an implicit atomicEnd is
+ * performed.
*)
- val switch': ('a t -> 'b t * (unit -> 'b)) -> 'a
+ val atomicSwitch: ('a t -> Runnable.t) -> 'a
end
signature MLTON_THREAD_EXTRA =
@@ -42,6 +63,6 @@
val amInSignalHandler: unit -> bool
val register: int * (unit -> unit) -> unit
- val setHandler: (unit t -> unit t) -> unit
+ val setHandler: (Runnable.t -> Runnable.t) -> unit
val switchToHandler: unit -> unit
end
1.4 +7 -1 mlton/lib/mlton-stubs/thread.sml
Index: thread.sml
===================================================================
RCS file: /cvsroot/mlton/mlton/lib/mlton-stubs/thread.sml,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- thread.sml 14 Apr 2004 01:12:47 -0000 1.3
+++ thread.sml 25 Aug 2004 17:51:07 -0000 1.4
@@ -13,8 +13,14 @@
type 'a t = unit
+ structure Runnable =
+ struct
+ type t = unit
+ end
+
+ val atomicSwitch = fn _ => raise Fail "Thread.atomicSwitch"
val new = fn _ => raise Fail "Thread.new"
+ val prepare = fn _ => raise Fail "Thread.prepare"
val prepend = fn _ => raise Fail "Thread.prepend"
val switch = fn _ => raise Fail "Thread.switch"
- val switch' = fn _ => raise Fail "Thread.switch'"
end
1.5 +1 -1 mlton/lib/mlton-stubs/world.sig
Index: world.sig
===================================================================
RCS file: /cvsroot/mlton/mlton/lib/mlton-stubs/world.sig,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- world.sig 13 Jan 2004 04:37:57 -0000 1.4
+++ world.sig 25 Aug 2004 17:51:07 -0000 1.5
@@ -5,5 +5,5 @@
datatype status = Clone | Original
val save: string -> status
(* Save the world to resume with the given thread. *)
- val saveThread: string * unit MLtonThread.t -> unit
+ val saveThread: string * MLtonThread.Runnable.t -> unit
end
1.56 +2 -3 mlton/mlton/codegen/x86-codegen/x86-codegen.fun
Index: x86-codegen.fun
===================================================================
RCS file: /cvsroot/mlton/mlton/mlton/codegen/x86-codegen/x86-codegen.fun,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -r1.55 -r1.56
--- x86-codegen.fun 1 May 2004 00:49:38 -0000 1.55
+++ x86-codegen.fun 25 Aug 2004 17:51:08 -0000 1.56
@@ -135,10 +135,9 @@
val additionalMainArgs =
let
val mainLabel = Label.toString (#label main)
- (* Drop the leading _ with Cygwin, because gcc will add it.
- *)
+ (* Drop the leading _, because gcc will add it. *)
val mainLabel =
- if let open Control in !targetOS = Cygwin end
+ if !Control.labelsHaveExtra_
then String.dropPrefix (mainLabel, 1)
else mainLabel
in
1.30 +4 -6 mlton/mlton/codegen/x86-codegen/x86-mlton-basic.fun
Index: x86-mlton-basic.fun
===================================================================
RCS file: /cvsroot/mlton/mlton/mlton/codegen/x86-codegen/x86-mlton-basic.fun,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- x86-mlton-basic.fun 12 Apr 2004 17:53:00 -0000 1.29
+++ x86-mlton-basic.fun 25 Aug 2004 17:51:08 -0000 1.30
@@ -353,15 +353,13 @@
* save gcState.frontier and gcState.stackTop, make call).
* However, there are probably cases where this is different.
*
- * We also have another hack because with Cygwin, Label.toString appends
+ * We also have another hack because on some platforms, Label.toString appends
* an _ to the beginning of each label.
*)
val fileLineLabel =
- Promise.lazy
- (fn () =>
- Label.fromString (if let open Control in !targetOS = Cygwin end
- then "_LINE__"
- else "__LINE__"))
+ Promise.lazy (fn () => Label.fromString (if !Control.labelsHaveExtra_
+ then "_LINE__"
+ else "__LINE__"))
val fileLine
= fn () => if !Control.debug
1.55 +1 -1 mlton/mlton/codegen/x86-codegen/x86.fun
Index: x86.fun
===================================================================
RCS file: /cvsroot/mlton/mlton/mlton/codegen/x86-codegen/x86.fun,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -r1.54 -r1.55
--- x86.fun 14 Aug 2004 01:34:52 -0000 1.54
+++ x86.fun 25 Aug 2004 17:51:08 -0000 1.55
@@ -48,7 +48,7 @@
open Label
fun toString l =
- if let open Control in !targetOS = Cygwin end
+ if !Control.labelsHaveExtra_
then concat ["_", Label.toString l]
else Label.toString l
1.107 +5 -0 mlton/mlton/control/control.sig
Index: control.sig
===================================================================
RCS file: /cvsroot/mlton/mlton/mlton/control/control.sig,v
retrieving revision 1.106
retrieving revision 1.107
diff -u -r1.106 -r1.107
--- control.sig 4 Aug 2004 03:15:09 -0000 1.106
+++ control.sig 25 Aug 2004 17:51:09 -0000 1.107
@@ -145,6 +145,11 @@
(* Save the SSA to a file. *)
val keepSSA: bool ref
+ (* For the codegen -- do labels for gcc and assembler need an extra leading
+ * underscore.
+ *)
+ val labelsHaveExtra_: bool ref
+
(* lib/mlton directory *)
val libDir: Dir.t ref
1.136 +4 -0 mlton/mlton/control/control.sml
Index: control.sml
===================================================================
RCS file: /cvsroot/mlton/mlton/mlton/control/control.sml,v
retrieving revision 1.135
retrieving revision 1.136
diff -u -r1.135 -r1.136
--- control.sml 17 Aug 2004 18:21:19 -0000 1.135
+++ control.sml 25 Aug 2004 17:51:09 -0000 1.136
@@ -431,6 +431,10 @@
(Layout.toString o
Regexp.Compiled.layout)}
+val labelsHaveExtra_ = control {name = "extra_",
+ default = false,
+ toString = Bool.toString}
+
val libDir = control {name = "lib dir",
default = "<libDir unset>",
toString = fn s => s}
1.118 +8 -1 mlton/mlton/elaborate/elaborate-core.fun
Index: elaborate-core.fun
===================================================================
RCS file: /cvsroot/mlton/mlton/mlton/elaborate/elaborate-core.fun,v
retrieving revision 1.117
retrieving revision 1.118
diff -u -r1.117 -r1.118
--- elaborate-core.fun 20 Aug 2004 16:34:46 -0000 1.117
+++ elaborate-core.fun 25 Aug 2004 17:51:10 -0000 1.118
@@ -753,7 +753,14 @@
SOME (case a of
Attribute.Cdecl => Convention.Cdecl
| Attribute.Stdcall =>
- if !Control.targetOS = MLton.Platform.OS.Cygwin
+ if let
+ open Control
+ in
+ case !targetOS of
+ Cygwin => true
+ | MinGW => true
+ | _ => false
+ end
then Convention.Stdcall
else Convention.Cdecl)
| _ => NONE
1.7 +3 -4 mlton/mlton/main/lookup-constant.fun
Index: lookup-constant.fun
===================================================================
RCS file: /cvsroot/mlton/mlton/mlton/main/lookup-constant.fun,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- lookup-constant.fun 28 May 2004 16:15:47 -0000 1.6
+++ lookup-constant.fun 25 Aug 2004 17:51:10 -0000 1.7
@@ -96,10 +96,9 @@
List.foreach
(List.concat
[["#include <stddef.h>", (* for offsetof *)
- "#include <stdio.h>"],
- List.map (["libmlton.h"], fn i =>
- concat ["#include <", i, ">"]),
- ["struct GC_state gcState;",
+ "#include <stdio.h>",
+ "#include \"platform.h\"",
+ "struct GC_state gcState;",
"int main (int argc, char **argv) {"],
List.revMap
(constants, fn {name, value, ty} =>
1.60 +17 -3 mlton/mlton/main/main.fun
Index: main.fun
===================================================================
RCS file: /cvsroot/mlton/mlton/mlton/main/main.fun,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -r1.59 -r1.60
--- main.fun 24 Aug 2004 23:53:43 -0000 1.59
+++ main.fun 25 Aug 2004 17:51:10 -0000 1.60
@@ -526,6 +526,11 @@
val targetArch = !targetArch
val archStr = String.toLower (MLton.Platform.Arch.toString targetArch)
val targetOS = !targetOS
+ val () =
+ Control.labelsHaveExtra_ := (case targetOS of
+ Cygwin => true
+ | MinGW => true
+ | _ => false)
val OSStr = String.toLower (MLton.Platform.OS.toString targetOS)
fun tokenize l =
String.tokens (concat (List.separate (l, " ")), Char.isSpace)
@@ -682,9 +687,16 @@
else ()
val tempFiles: File.t list ref = ref []
val tmpDir =
- case Process.getEnv "TMPDIR" of
- NONE => "/tmp"
- | SOME d => d
+ let
+ val (tmpVar, default) =
+ case targetOS of
+ MinGW => ("TEMP", "C:/WINNT/TEMP")
+ | _ => ("TMPDIR", "/tmp")
+ in
+ case Process.getEnv tmpVar of
+ NONE => default
+ | SOME d => d
+ end
fun temp (suf: string): File.t =
let
val (f, out) =
@@ -740,6 +752,8 @@
* Notice that we do not use targetOS here, since we
* care about the platform we're running on, not the
* platform we're generating for.
+ *
+ * We want to keep the .exe as is for MinGW/Win32.
*)
val _ =
if MLton.Platform.OS.host = Cygwin
1.84 +34 -119 mlton/runtime/Makefile
Index: Makefile
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Makefile,v
retrieving revision 1.83
retrieving revision 1.84
diff -u -r1.83 -r1.84
--- Makefile 1 May 2004 17:39:02 -0000 1.83
+++ Makefile 25 Aug 2004 17:51:10 -0000 1.84
@@ -7,11 +7,18 @@
TARGET = self
TARGET_ARCH = $(shell ../bin/host-arch)
+TARGET_OS = $(shell ../bin/host-os)
+GCC_VERSION = $(shell gcc -v 2>&1 | grep 'gcc version' | sed 's/.*gcc version \(.\).*/\1/')
FLAGS = -fomit-frame-pointer
ifeq ($(TARGET_ARCH), x86)
-FLAGS += -mcpu=pentiumpro -malign-loops=2 -malign-jumps=2 -malign-functions=5
+FLAGS += -mcpu=pentiumpro
+ifeq ($(GCC_VERSION), 3)
+FLAGS += -falign-loops=2 -falign-jumps=2 -falign-functions=5
+else
+FLAGS += -malign-loops=2 -malign-jumps=2 -malign-functions=5
+endif
endif
ifeq ($(TARGET_ARCH), sparc)
FLAGS += -Wa,-xarch=v8plusa -fcall-used-g5 -fcall-used-g7 -funroll-all-loops -m32 -mv8 -mcpu=ultrasparc
@@ -24,7 +31,7 @@
FLAGS += -b $(TARGET)
endif
-CC = gcc -Wall -I. -Igdtoa -D_FILE_OFFSET_BITS=64 $(FLAGS)
+CC = gcc -Wall -I. -D_FILE_OFFSET_BITS=64 $(FLAGS)
CFLAGS = -O2
DEBUGFLAGS = -gstabs+ -g2
@@ -33,8 +40,7 @@
basis/CommandLine.o \
basis/Date.o \
basis/Debug.o \
- basis/GC/setMessages.o \
- basis/GC/setSummary.o \
+ basis/GC.o \
basis/IEEEReal.o \
basis/IntInf.o \
basis/Int/Word.o \
@@ -56,27 +62,11 @@
basis/Net/NetHostDB.o \
basis/Net/NetProtDB.o \
basis/Net/NetServDB.o \
- basis/Net/Socket/Ctl.o \
basis/Net/Socket/INetSock.o \
- basis/Net/Socket/UnixSock.o \
- basis/Net/Socket/accept.o \
- basis/Net/Socket/bind.o \
- basis/Net/Socket/close.o \
- basis/Net/Socket/connect.o \
- basis/Net/Socket/familyOfAddr.o \
- basis/Net/Socket/listen.o \
- basis/Net/Socket/recv.o \
- basis/Net/Socket/recvFrom.o \
- basis/Net/Socket/send.o \
- basis/Net/Socket/sendTo.o \
- basis/Net/Socket/shutdown.o \
- basis/Net/Socket/socket.o \
- basis/Net/Socket/socketPair.o \
+ basis/Net/Socket/Socket.o \
basis/OS/IO/poll.o \
- basis/PackReal/subVec.o \
- basis/PackReal/update.o \
- basis/Ptrace/ptrace2.o \
- basis/Ptrace/ptrace4.o \
+ basis/PackReal.o \
+ basis/Ptrace.o \
basis/Real/class.o \
basis/Real/frexp.o \
basis/Real/gdtoa.o \
@@ -88,20 +78,9 @@
basis/Stdio.o \
basis/Thread.o \
basis/Time.o \
- Posix/Error/clearErrno.o \
- Posix/Error/getErrno.o \
- Posix/Error/strerror.o \
- Posix/FileSys/Dirstream/closedir.o \
- Posix/FileSys/Dirstream/opendir.o \
- Posix/FileSys/Dirstream/readdir.o \
- Posix/FileSys/Dirstream/rewinddir.o \
- Posix/FileSys/ST/isBlk.o \
- Posix/FileSys/ST/isChr.o \
- Posix/FileSys/ST/isDir.o \
- Posix/FileSys/ST/isFIFO.o \
- Posix/FileSys/ST/isLink.o \
- Posix/FileSys/ST/isReg.o \
- Posix/FileSys/ST/isSock.o \
+ Posix/Error.o \
+ Posix/FileSys/Dirstream.o \
+ Posix/FileSys/ST.o \
Posix/FileSys/Stat.o \
Posix/FileSys/Utimbuf.o \
Posix/FileSys/access.o \
@@ -135,26 +114,16 @@
Posix/IO/pipe.o \
Posix/IO/read.o \
Posix/IO/write.o \
+ Posix/ProcEnv/ProcEnv.o \
Posix/ProcEnv/Tms.o \
Posix/ProcEnv/Uname.o \
- Posix/ProcEnv/ctermid.o \
Posix/ProcEnv/environ.o \
Posix/ProcEnv/getenv.o \
- Posix/ProcEnv/getegid.o \
- Posix/ProcEnv/geteuid.o \
- Posix/ProcEnv/getgid.o \
Posix/ProcEnv/getgroups.o \
Posix/ProcEnv/getlogin.o \
Posix/ProcEnv/getpgrp.o \
- Posix/ProcEnv/getpid.o \
- Posix/ProcEnv/getppid.o \
- Posix/ProcEnv/getuid.o \
Posix/ProcEnv/isatty.o \
Posix/ProcEnv/setenv.o \
- Posix/ProcEnv/setgid.o \
- Posix/ProcEnv/setpgid.o \
- Posix/ProcEnv/setsid.o \
- Posix/ProcEnv/setuid.o \
Posix/ProcEnv/sysconf.o \
Posix/ProcEnv/ttyname.o \
Posix/Process/alarm.o \
@@ -172,29 +141,20 @@
Posix/Process/stopSig.o \
Posix/Process/termSig.o \
Posix/Process/waitpid.o \
- Posix/Signal/Signal.o \
- Posix/Signal/isPending.o \
- Posix/Signal/resetPending.o \
+ Posix/Signal.o \
Posix/SysDB/Group.o \
Posix/SysDB/Passwd.o \
- Posix/TTY/Termios.o \
- Posix/TTY/drain.o \
- Posix/TTY/flow.o \
- Posix/TTY/flush.o \
- Posix/TTY/getpgrp.o \
- Posix/TTY/sendbreak.o \
- Posix/TTY/setpgrp.o \
+ Posix/TTY.o \
gc.o \
- libmlton.o \
- my-lib.o
+ platform.o \
+ platform/$(TARGET_OS).o
DEBUG_OBJS = \
basis/Array/numElements-gdb.o \
basis/CommandLine-gdb.o \
basis/Date-gdb.o \
basis/Debug-gdb.o \
- basis/GC/setMessages-gdb.o \
- basis/GC/setSummary-gdb.o \
+ basis/GC-gdb.o \
basis/IEEEReal-gdb.o \
basis/IntInf-gdb.o \
basis/Int/Word-gdb.o \
@@ -216,52 +176,25 @@
basis/Net/NetHostDB-gdb.o \
basis/Net/NetProtDB-gdb.o \
basis/Net/NetServDB-gdb.o \
- basis/Net/Socket/Ctl-gdb.o \
basis/Net/Socket/INetSock-gdb.o \
- basis/Net/Socket/UnixSock-gdb.o \
- basis/Net/Socket/accept-gdb.o \
- basis/Net/Socket/bind-gdb.o \
- basis/Net/Socket/close-gdb.o \
- basis/Net/Socket/connect-gdb.o \
- basis/Net/Socket/familyOfAddr-gdb.o \
- basis/Net/Socket/listen-gdb.o \
- basis/Net/Socket/recv-gdb.o \
- basis/Net/Socket/recvFrom-gdb.o \
- basis/Net/Socket/send-gdb.o \
- basis/Net/Socket/sendTo-gdb.o \
- basis/Net/Socket/shutdown-gdb.o \
- basis/Net/Socket/socket-gdb.o \
- basis/Net/Socket/socketPair-gdb.o \
+ basis/Net/Socket/Socket-gdb.o \
basis/OS/IO/poll-gdb.o \
- basis/PackReal/subVec-gdb.o \
- basis/PackReal/update-gdb.o \
- basis/Ptrace/ptrace2-gdb.o \
- basis/Ptrace/ptrace4-gdb.o \
+ basis/PackReal-gdb.o \
+ basis/Ptrace-gdb.o \
basis/Real/class-gdb.o \
basis/Real/frexp-gdb.o \
basis/Real/gdtoa-gdb.o \
basis/Real/modf-gdb.o \
- basis/Real/nextAfter-gdb.o \
+ basis/Real/nextAfter-gdb.o \
basis/Real/real-gdb.o \
basis/Real/signBit-gdb.o \
basis/Real/strto-gdb.o \
basis/Stdio-gdb.o \
basis/Thread-gdb.o \
basis/Time-gdb.o \
- Posix/Error/clearErrno-gdb.o \
- Posix/Error/getErrno-gdb.o \
- Posix/Error/strerror-gdb.o \
- Posix/FileSys/Dirstream/closedir-gdb.o \
- Posix/FileSys/Dirstream/opendir-gdb.o \
- Posix/FileSys/Dirstream/readdir-gdb.o \
- Posix/FileSys/Dirstream/rewinddir-gdb.o \
- Posix/FileSys/ST/isBlk-gdb.o \
- Posix/FileSys/ST/isChr-gdb.o \
- Posix/FileSys/ST/isDir-gdb.o \
- Posix/FileSys/ST/isFIFO-gdb.o \
- Posix/FileSys/ST/isLink-gdb.o \
- Posix/FileSys/ST/isReg-gdb.o \
- Posix/FileSys/ST/isSock-gdb.o \
+ Posix/Error-gdb.o \
+ Posix/FileSys/Dirstream-gdb.o \
+ Posix/FileSys/ST-gdb.o \
Posix/FileSys/Stat-gdb.o \
Posix/FileSys/Utimbuf-gdb.o \
Posix/FileSys/access-gdb.o \
@@ -295,26 +228,16 @@
Posix/IO/pipe-gdb.o \
Posix/IO/read-gdb.o \
Posix/IO/write-gdb.o \
+ Posix/ProcEnv/ProcEnv-gdb.o \
Posix/ProcEnv/Tms-gdb.o \
Posix/ProcEnv/Uname-gdb.o \
- Posix/ProcEnv/ctermid-gdb.o \
Posix/ProcEnv/environ-gdb.o \
Posix/ProcEnv/getenv-gdb.o \
- Posix/ProcEnv/getegid-gdb.o \
- Posix/ProcEnv/geteuid-gdb.o \
- Posix/ProcEnv/getgid-gdb.o \
Posix/ProcEnv/getgroups-gdb.o \
Posix/ProcEnv/getlogin-gdb.o \
Posix/ProcEnv/getpgrp-gdb.o \
- Posix/ProcEnv/getpid-gdb.o \
- Posix/ProcEnv/getppid-gdb.o \
- Posix/ProcEnv/getuid-gdb.o \
Posix/ProcEnv/isatty-gdb.o \
Posix/ProcEnv/setenv-gdb.o \
- Posix/ProcEnv/setgid-gdb.o \
- Posix/ProcEnv/setpgid-gdb.o \
- Posix/ProcEnv/setsid-gdb.o \
- Posix/ProcEnv/setuid-gdb.o \
Posix/ProcEnv/sysconf-gdb.o \
Posix/ProcEnv/ttyname-gdb.o \
Posix/Process/alarm-gdb.o \
@@ -332,21 +255,13 @@
Posix/Process/stopSig-gdb.o \
Posix/Process/termSig-gdb.o \
Posix/Process/waitpid-gdb.o \
- Posix/Signal/Signal-gdb.o \
- Posix/Signal/isPending-gdb.o \
- Posix/Signal/resetPending-gdb.o \
+ Posix/Signal-gdb.o \
Posix/SysDB/Group-gdb.o \
Posix/SysDB/Passwd-gdb.o \
- Posix/TTY/Termios-gdb.o \
- Posix/TTY/drain-gdb.o \
- Posix/TTY/flow-gdb.o \
- Posix/TTY/flush-gdb.o \
- Posix/TTY/getpgrp-gdb.o \
- Posix/TTY/sendbreak-gdb.o \
- Posix/TTY/setpgrp-gdb.o \
+ Posix/TTY-gdb.o \
gc-gdb.o \
- libmlton-gdb.o \
- my-lib-gdb.o
+ platform-gdb.o \
+ platform/$(TARGET_OS)-gdb.o
all: libgdtoa.a libmlton.a libmlton-gdb.a
1.198 +56 -327 mlton/runtime/gc.c
Index: gc.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/gc.c,v
retrieving revision 1.197
retrieving revision 1.198
diff -u -r1.197 -r1.198
--- gc.c 18 Aug 2004 20:30:49 -0000 1.197
+++ gc.c 25 Aug 2004 17:51:10 -0000 1.198
@@ -6,68 +6,7 @@
* Please see the file MLton-LICENSE for license information.
*/
-#include "gc.h"
-#include <errno.h>
-#include <fcntl.h>
-#include <math.h>
-#include <string.h>
-
-#if (defined (__FreeBSD__))
-#include <sys/sysctl.h>
-#endif
-
-#if (defined (__NetBSD__) || defined (__OpenBSD__))
-#include <sys/param.h>
-#include <sys/sysctl.h>
-#endif
-
-#include <sys/mman.h>
-#include <sys/resource.h>
-#include <sys/times.h>
-#include <time.h>
-
-#if (defined (__CYGWIN__))
-#include <windows.h>
-#endif
-
-#if (defined (__linux__))
-#include <values.h>
-#include <sys/sysinfo.h>
-#endif
-
-#if (defined (__CYGWIN__) || defined (__FreeBSD__))
-#include <limits.h>
-#endif
-
-#if (defined (__linux__) || defined (__FreeBSD__) || defined (__sun__))
-#include <signal.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <ucontext.h>
-#endif
-
-#include "IntInf.h"
-
-/* SUPPORTS_WEAK is true if the platform supports the weak attribute. */
-#if (defined (__FreeBSD__) || defined (__linux__) || defined (__NetBSD__) || defined (__OpenBSD__) || defined (__sun__))
-#define SUPPORTS_WEAK 1
-#elif (defined (__CYGWIN__))
-#define SUPPORTS_WEAK 0
-#else
-#error SUPPORTS_WEAK not defined on platform
-#endif
-
-/* On Linux, We need the value of MREMAP_MAYMOVE, which should come from
- * sys/mman.h, but isn't there. It is in linux/mman.h, but we can't #include
- * that here, because kernel headers don't mix with system headers. We could
- * create a separate file, include the kernel headers there, and define a global.
- * But there sometimes seem to be problems including kernel headers, so the
- * easiest thing to do is just define MREMAP_MAYMOVE.
- */
-#if (defined (__linux__))
-#define MREMAP_MAYMOVE 1
-#endif
+#include "platform.h"
/* The mutator should maintain the invariants
*
@@ -94,7 +33,6 @@
DEBUG_MEM = FALSE,
DEBUG_PROFILE = FALSE,
DEBUG_RESIZING = FALSE,
- DEBUG_SIGNALS = FALSE,
DEBUG_STACKS = FALSE,
DEBUG_THREADS = FALSE,
DEBUG_WEAK = FALSE,
@@ -158,16 +96,6 @@
return n << 2;
}
-#if (defined (__FreeBSD__) || defined (__linux__) || defined (__NetBSD__) || defined (__OpenBSD__) || defined (__sun__))
-static inline uint min (uint x, uint y) {
- return ((x < y) ? x : y);
-}
-
-static inline uint max (uint x, uint y) {
- return ((x > y) ? x : y);
-}
-#endif
-
static inline W64 min64 (W64 x, W64 y) {
return ((x < y) ? x : y);
}
@@ -247,129 +175,11 @@
/* Virtual Memory Management */
/* ---------------------------------------------------------------- */
-#if (defined (__CYGWIN__))
-
-static void showMaps () {
- MEMORY_BASIC_INFORMATION buf;
- LPCVOID lpAddress;
- char *state = "<unset>";
- char *protect = "<unset>";
-
- for (lpAddress = 0; lpAddress < (LPCVOID)0x80000000; ) {
- VirtualQuery (lpAddress, &buf, sizeof (buf));
-
- switch (buf.Protect) {
- case PAGE_READONLY:
- protect = "PAGE_READONLY";
- break;
- case PAGE_READWRITE:
- protect = "PAGE_READWRITE";
- break;
- case PAGE_WRITECOPY:
- protect = "PAGE_WRITECOPY";
- break;
- case PAGE_EXECUTE:
- protect = "PAGE_EXECUTE";
- break;
- case PAGE_EXECUTE_READ:
- protect = "PAGE_EXECUTE_READ";
- break;
- case PAGE_EXECUTE_READWRITE:
- protect = "PAGE_EXECUTE_READWRITE";
- break;
- case PAGE_EXECUTE_WRITECOPY:
- protect = "PAGE_EXECUTE_WRITECOPY";
- break;
- case PAGE_GUARD:
- protect = "PAGE_GUARD";
- break;
- case PAGE_NOACCESS:
- protect = "PAGE_NOACCESS";
- break;
- case PAGE_NOCACHE:
- protect = "PAGE_NOCACHE";
- break;
- }
- switch (buf.State) {
- case MEM_COMMIT:
- state = "MEM_COMMIT";
- break;
- case MEM_FREE:
- state = "MEM_FREE";
- break;
- case MEM_RESERVE:
- state = "MEM_RESERVE";
- break;
- }
- fprintf(stderr, "0x%8x %10u %s %s\n",
- (uint)buf.BaseAddress,
- (uint)buf.RegionSize,
- state, protect);
- lpAddress += buf.RegionSize;
- }
-}
-
-static void showMem () {
- MEMORYSTATUS ms;
-
- ms.dwLength = sizeof (MEMORYSTATUS);
- GlobalMemoryStatus (&ms);
- fprintf(stderr, "Total Phys. Mem: %ld\nAvail Phys. Mem: %ld\nTotal Page File: %ld\nAvail Page File: %ld\nTotal Virtual: %ld\nAvail Virtual: %ld\n",
- ms.dwTotalPhys,
- ms.dwAvailPhys,
- ms.dwTotalPageFile,
- ms.dwAvailPageFile,
- ms.dwTotalVirtual,
- ms.dwAvailVirtual);
- showMaps();
-}
-
-#elif (defined (__FreeBSD__))
-
-static void showMem () {
- static char buffer[256];
-
- sprintf (buffer, "/bin/cat /proc/%d/map\n", (int)getpid ());
- (void)system (buffer);
-}
-
-#elif (defined (__linux__) || defined (__NetBSD__) || defined (__OpenBSD__))
-
-static void showMem () {
- static char buffer[256];
-
- sprintf (buffer, "/bin/cat /proc/%d/maps\n", (int)getpid ());
- (void)system (buffer);
-}
-
-#elif (defined (__sun__))
-
-static void showMem () {
- static char buffer[256];
- sprintf (buffer, "pmap %d\n", (int)getpid ());
- system (buffer);
-}
-
-#else
-
-#error showMem not defined on platform
-
-#endif
-
-/* On any platform, exactly one of {USE_MMAP, USE_VIRTUAL_ALLOC} should be set
- * to true.
- */
-#if (defined (__FreeBSD__) || defined (__linux__) || defined (__NetBSD__) || defined (__OpenBSD__) || defined (__sun__))
-#define USE_MMAP TRUE
-#elif (defined (__CYGWIN__))
-#define USE_VIRTUAL_ALLOC TRUE
-#else
-#error must define USE_MMAP or USE_VIRTUAL_ALLOC
-#endif
-
static void *mmapAnon (void *start, size_t length) {
+#if USE_MMAP
static int fd = -1;
int flags;
+#endif
void *result;
#if USE_VIRTUAL_ALLOC
@@ -397,7 +207,7 @@
return result;
}
-static void *smmap (size_t length) {
+void *smmap (size_t length) {
void *result;
result = mmapAnon (NULL, length);
@@ -422,36 +232,6 @@
}
#endif
-#if (defined (__FreeBSD__) || defined (__linux__) || defined (__NetBSD__) || defined (__OpenBSD__) || defined (__sun__))
-/* A super-safe mmap.
- * Allocates a region of memory with dead zones at the high and low ends.
- * Any attempt to touch the dead zone (read or write) will cause a
- * segmentation fault.
- */
-static void *ssmmap (size_t length, size_t dead_low, size_t dead_high) {
- void *base,*low,*result,*high;
-
- base = smmap (length + dead_low + dead_high);
- low = base;
- if (mprotect (low, dead_low, PROT_NONE))
- diee ("mprotect failed");
- result = low + dead_low;
- high = result + length;
- if (mprotect (high, dead_high, PROT_NONE))
- diee ("mprotect failed");
- return result;
-}
-
-#elif (defined (__CYGWIN__))
-
-/* Nothing needed. */
-
-#else
-
-#error ssmmap not defined on platform
-
-#endif
-
static void release (void *base, size_t length) {
if (DEBUG_MEM)
fprintf (stderr, "release (0x%08x, %s)\n",
@@ -631,10 +411,14 @@
/* Return time as number of milliseconds. */
static uint currentTime () {
+#if (defined(__MSVCRT__))
+ return GetTickCount();
+#else
struct rusage ru;
fixedGetrusage (RUSAGE_SELF, &ru);
return rusageTime (&ru);
+#endif
}
static inline void startTiming (struct rusage *ru_start) {
@@ -952,6 +736,7 @@
maybeCall (f, s, (pointer*)&s->signalHandler);
}
+#if ASSERT
static pointer arrayPointer (GC_state s,
pointer a,
uint arrayIndex,
@@ -969,6 +754,7 @@
+ numNonPointers
+ pointerIndex * POINTER_SIZE;
}
+#endif
/* The number of bytes in an array, not including the header. */
static inline uint arrayNumBytes (GC_state s,
@@ -2758,13 +2544,13 @@
/* heapRemap */
/* ---------------------------------------------------------------- */
-#if (defined (__CYGWIN__) || defined (__FreeBSD__) || defined (__NetBSD__) || defined (__OpenBSD__) || defined (__sun__))
+#if !HAS_MREMAP
static bool heapRemap (GC_state s, GC_heap h, W32 desired, W32 minSize) {
return FALSE;
}
-#elif (defined (__linux__))
+#else
static bool heapRemap (GC_state s, GC_heap h, W32 desired, W32 minSize) {
W32 backoff;
@@ -2799,11 +2585,7 @@
return FALSE;
}
-#else
-
-#error heapRemap not defined
-
-#endif
+#endif /* HAS_MREMAP */
/* ---------------------------------------------------------------- */
/* heapGrow */
@@ -2858,12 +2640,19 @@
int fd;
FILE *stream;
char template[80];
+ char *tmpDefault;
char *tmpDir;
+ char *tmpVar;
- tmpDir = getenv ("TMPDIR");
- if (NULL == tmpDir)
- tmpDir = "/tmp";
- strcpy (template, tmpDir);
+#if (defined (__MSVCRT__))
+ tmpVar = "TEMP";
+ tmpDefault = "C:/WINNT/TEMP";
+#else
+ tmpVar = "TMPDIR";
+ tmpDefault = "/tmp";
+#endif
+ tmpDir = getenv (tmpVar);
+ strcpy (template, (NULL == tmpDir) ? tmpDefault : tmpDir);
strcat (template, "/FromSpaceXXXXXX");
fd = smkstemp (template);
sclose (fd);
@@ -3050,8 +2839,7 @@
void MLton_Rusage_ru ();
#endif
static inline bool needGCTime (GC_state s) {
- return DEBUG or s->summary or s->messages
- or (0 != MLton_Rusage_ru != 0);
+ return DEBUG or s->summary or s->messages or (0 != MLton_Rusage_ru);
}
static void doGC (GC_state s,
@@ -3818,11 +3606,16 @@
profileWriteCount (s, p, fd, i + s->sourcesSize);
}
-#if (defined (__linux__) || defined (__FreeBSD__) || defined (__NetBSD__) || defined (__OpenBSD__) || defined (__sun__))
+#if not HAS_TIME_PROFILING
-#ifndef EIP
-#define EIP 14
-#endif
+/* No time profiling on this platform. There is a check in mlton/main/main.fun
+ * to make sure that time profiling is never turned on.
+ */
+static void profileTimeInit (GC_state s) {
+ die ("no time profiling");
+}
+
+#else
static GC_state catcherState;
@@ -3843,6 +3636,9 @@
s = catcherState;
#if (defined (__linux__))
+#ifndef EIP
+#define EIP 14
+#endif
pc = (pointer) ucp->uc_mcontext.gregs[EIP];
#elif (defined (__FreeBSD__))
pc = (pointer) ucp->uc_mcontext.mc_eip;
@@ -3959,19 +3755,6 @@
setProfTimer (10000);
}
-#elif (defined (__CYGWIN__))
-
-/* No time profiling on this platform. There is a check in mlton/main/main.fun
- * to make sure that time profiling is never turned on.
- */
-static void profileTimeInit (GC_state s) {
- die ("no time profiling");
-}
-
-#else
-
-#error time profiling not implemented
-
#endif
/* profileEnd is for writing out an mlmon.out file even if the C code terminates
@@ -4000,12 +3783,7 @@
/* ---------------------------------------------------------------- */
static void initSignalStack (GC_state s) {
-#if (defined (__CYGWIN__))
-
- /* Nothing */
-
-#elif (defined (__FreeBSD__) || defined (__linux__) || defined (__NetBSD__) || defined (__OpenBSD__) || defined (__sun__))
-
+#if HAS_SIGALTSTACK
static stack_t altstack;
size_t ss_size = align (SIGSTKSZ, s->pageSize);
size_t psize = s->pageSize;
@@ -4014,75 +3792,9 @@
altstack.ss_size = ss_size;
altstack.ss_flags = 0;
sigaltstack (&altstack, NULL);
-
-#else
-
-#error initSignalStack not defined
-
-#endif
-}
-
-static int processor_has_sse2=0;
-
-static void readProcessor() {
-#if 0
- int status = system("/bin/cat /proc/cpuinfo | /bin/egrep -q '^flags.*:.* mmx .*xmm'");
-
- if (status==0)
- processor_has_sse2=1;
- else
- processor_has_sse2=0;
#endif
- processor_has_sse2=0;
-}
-
-/*
- * totalRam returns the amount of physical memory on the machine. This is
- * later multiplied by ramSlop to cut down on using all memory and paging.
- */
-
-#if (defined (__CYGWIN__) || defined (__linux__) || defined (__sun__))
-
-static W32 totalRam (GC_state s) {
- W32 maxMem;
- W64 tmp;
-
- maxMem = 0x100000000llu - s->pageSize;
- tmp = sysconf (_SC_PHYS_PAGES) * (W64)s->pageSize;
- return (tmp >= maxMem) ? maxMem: (W32)tmp;
-}
-
-#elif (defined (__FreeBSD__))
-
-static W32 totalRam (GC_state s) {
- int mem, len;
-
- len = sizeof (int);
- if (-1 == sysctlbyname ("hw.physmem", &mem, &len, NULL, 0))
- diee ("sysctl failed");
- return mem;
}
-#elif (defined (__NetBSD__) || defined (__OpenBSD__))
-
-static W32 totalRam (GC_state s) {
- uint mem;
- int len, mib[2];
-
- mib[0] = CTL_HW;
- mib[1] = HW_PHYSMEM;
- len = sizeof(mem);
- if (-1 == sysctl (mib, 2, &mem, &len, NULL, 0))
- diee ("sysctl failed");
- return mem;
-}
-
-#else
-
-#error totalRam not defined
-
-#endif /* definition of totalRam */
-
#if FALSE
static bool stringToBool (string s) {
if (0 == strcmp (s, "false"))
@@ -4396,7 +4108,11 @@
s->messages = TRUE;
} else if (0 == strcmp (arg, "gc-summary")) {
++i;
+#if (defined (__MINGW32__))
+ fprintf (stderr, "Warning: MinGW doesn't yet support gc-summary\n");
+#else
s->summary = TRUE;
+#endif
} else if (0 == strcmp (arg, "copy-generational-ratio")) {
++i;
if (i == argc)
@@ -4546,7 +4262,6 @@
rusageZero (&s->ru_gcCopy);
rusageZero (&s->ru_gcMarkCompact);
rusageZero (&s->ru_gcMinor);
- readProcessor ();
worldFile = NULL;
unless (isAligned (s->pageSize, s->cardSize))
die ("Page size must be a multiple of card size.");
@@ -4617,6 +4332,20 @@
}
s->amInGC = FALSE;
return i;
+}
+
+extern char **environ; /* for Posix_ProcEnv_environ */
+
+void MLton_init (int argc, char **argv, GC_state s) {
+ int start;
+
+ Posix_ProcEnv_environ = (CstringArray)environ;
+ start = GC_init (s, argc, argv);
+ /* Setup argv and argc that SML sees. */
+ /* start is now the index of the first real arg. */
+ CommandLine_commandName = (uint)(argv[0]);
+ CommandLine_argc = argc - start;
+ CommandLine_argv = (uint)(argv + start);
}
static void displayCol (FILE *out, int width, string s) {
1.78 +2 -12 mlton/runtime/gc.h
Index: gc.h
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/gc.h,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -r1.77 -r1.78
--- gc.h 8 Aug 2004 18:41:34 -0000 1.77
+++ gc.h 25 Aug 2004 17:51:10 -0000 1.78
@@ -5,8 +5,6 @@
* MLton is released under the GNU General Public License (GPL).
* Please see the file MLton-LICENSE for license information.
*/
-#ifndef _MLTON_GC_H
-#define _MLTON_GC_H
/*
* A two-space stop-and-copy GC.
@@ -14,16 +12,7 @@
* Has three kinds of objects: normal (fixed size), arrays, and stacks.
*/
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/time.h>
-#include <sys/resource.h>
-
-#include "my-lib.h"
-
typedef uint word;
-typedef char* pointer;
typedef unsigned long long W64;
typedef unsigned long W32;
typedef W32 Header;
@@ -686,4 +675,5 @@
pointer GC_weakGet (pointer p);
pointer GC_weakNew (GC_state s, W32 header, pointer p);
-#endif /* #ifndef _MLTON_GC_H */
+/* initialize the machine */
+void MLton_init (int argc, char **argv, GC_state s);
1.7 +27 -3 mlton/runtime/types.h
Index: types.h
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/types.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- types.h 1 May 2004 00:49:48 -0000 1.6
+++ types.h 25 Aug 2004 17:51:10 -0000 1.7
@@ -4,14 +4,18 @@
* MLton is released under the GNU General Public License (GPL).
* Please see the file MLton-LICENSE for license information.
*/
-#ifndef _TYPES_H_
-#define _TYPES_H_
+
+/* Can't use _TYPES_H_ because MSVCRT uses it. So, we use _MLTON_TYPES_H_. */
+
+#ifndef _MLTON_TYPES_H_
+#define _MLTON_TYPES_H_
typedef char Int8;
typedef short Int16;
typedef long Int32;
typedef long long Int64;
typedef char *Pointer;
+typedef Pointer pointer;
typedef float Real32;
typedef double Real64;
typedef unsigned char Word8;
@@ -36,5 +40,25 @@
typedef Int64 Position;
typedef Int Bool;
+typedef Word Cpointer;
+typedef Word Cstring;
+typedef Word CstringArray;
+typedef Word Dirstream;
+typedef Int Fd;
+typedef Word Flag;
+typedef Word Gid;
+typedef Word Mode;
+typedef Word NullString;
+typedef Int Pid;
+typedef Int Resource;
+typedef Word Rlimit;
+typedef Int Signal;
+typedef Int Size;
+typedef Int Speed;
+typedef Int Ssize;
+typedef Int Status;
+typedef Int Syserror;
+typedef Pointer Thread;
+typedef Word Uid;
-#endif /* _TYPES_H_ */
+#endif /* _MY_TYPES_H_ */
1.1 mlton/runtime/platform.c
Index: platform.c
===================================================================
/* Copyright (C) 2004 Henry Cejtin, Matthew Fluet, Suresh
* Jagannathan, and Stephen Weeks.
*
* MLton is released under the GNU General Public License (GPL).
* Please see the file MLton-LICENSE for license information.
*/
#include "platform.h"
void die (char *fmt, ...) {
va_list args;
fflush(stdout);
va_start(args, fmt);
vfprintf(stderr, fmt, args);
va_end(args);
fprintf(stderr, "\n");
exit(1);
}
void diee (char * fmt, ...) {
va_list args;
fflush(stdout);
va_start(args, fmt);
vfprintf(stderr, fmt, args);
va_end(args);
fprintf(stderr, " (%s)\n", strerror(errno));
exit(1);
}
void asfail(char *file, int line, char *prop) {
fflush(stdout);
fprintf(stderr, "%s:%d: assert(%s) failed.\n", file, line, prop);
abort();
}
string boolToString (bool b) {
return b ? "TRUE" : "FALSE";
}
#define BUF_SIZE 81
string intToCommaString (int n) {
static char buf[BUF_SIZE];
int i;
i = BUF_SIZE - 1;
buf[i--] = '\000';
if (0 == n)
buf[i--] = '0';
else if (INT_MIN == n) {
/* must treat INT_MIN specially, because I negate stuff later */
strcpy (buf + 1, "-2,147,483,648");
i = 0;
} else {
int m;
if (n > 0) m = n; else m = -n;
while (m > 0) {
buf[i--] = m % 10 + '0';
m = m / 10;
if (i % 4 == 0 and m > 0) buf[i--] = ',';
}
if (n < 0) buf[i--] = '-';
}
return buf + i + 1;
}
void *scalloc (size_t nmemb, size_t size) {
void *res;
res = calloc (nmemb, size);
if (NULL == res)
die ("calloc (%s, %s) failed.\n",
uintToCommaString (nmemb),
uintToCommaString (size));
return res;
}
void sclose (int fd) {
unless (0 == close (fd))
diee ("unable to close %d", fd);
}
void sfclose (FILE *file) {
unless (0 == fclose (file))
diee ("unable to close file");
}
FILE *sfopen (char *fileName, char *mode) {
FILE *file;
if (NULL == (file = fopen ((char*)fileName, mode)))
diee ("sfopen unable to open file %s", fileName);
return file;
}
void sfread (void *ptr, size_t size, size_t nmemb, FILE *file) {
size_t bytes;
bytes = size * nmemb;
if (0 == bytes) return;
unless (1 == fread (ptr, bytes, 1, file))
diee("sfread failed");
}
uint sfreadUint (FILE *file) {
uint n;
sfread (&n, sizeof(uint), 1, file);
return n;
}
void sfwrite (void *ptr, size_t size, size_t nmemb, FILE *file) {
size_t bytes;
bytes = size * nmemb;
if (0 == bytes) return;
unless (1 == fwrite (ptr, size * nmemb, 1, file))
diee ("sfwrite failed");
}
void *smalloc (size_t length) {
void *res;
res = malloc (length);
if (NULL == res)
die ("Unable to malloc %s bytes.\n", uintToCommaString (length));
return res;
}
int smkstemp (char *template) {
int fd;
fd = mkstemp (template);
if (-1 == fd)
diee ("unable to make temporary file");
return fd;
}
void swrite (int fd, const void *buf, size_t count) {
if (0 == count) return;
unless (count == write (fd, buf, count))
diee ("swrite failed");
}
void swriteUint (int fd, uint n) {
swrite (fd, &n, sizeof(uint));
}
string uintToCommaString (uint n) {
static char buf1[BUF_SIZE];
static char buf2[BUF_SIZE];
static char buf3[BUF_SIZE];
static char buf4[BUF_SIZE];
static char buf5[BUF_SIZE];
static char *bufs[] = {buf1, buf2, buf3, buf4, buf5};
static int bufIndex = 0;
static char *buf;
int i;
buf = bufs[bufIndex++];
bufIndex %= 5;
i = BUF_SIZE - 1;
buf[i--] = '\000';
if (0 == n)
buf[i--] = '0';
else {
while (n > 0) {
buf[i--] = n % 10 + '0';
n = n / 10;
if (i % 4 == 0 and n > 0) buf[i--] = ',';
}
}
return buf + i + 1;
}
string ullongToCommaString (ullong n) {
static char buf[BUF_SIZE];
int i;
i = BUF_SIZE - 1;
buf[i--] = '\000';
if (0 == n)
buf[i--] = '0';
else {
while (n > 0) {
buf[i--] = n % 10 + '0';
n = n / 10;
if (i % 4 == 0 and n > 0) buf[i--] = ',';
}
}
return buf + i + 1;
}
1.1 mlton/runtime/platform.h
Index: platform.h
===================================================================
/* Copyright (C) 1999-2004 Henry Cejtin, Matthew Fluet, Suresh
* Jagannathan, and Stephen Weeks.
* Copyright (C) 1997-1999 NEC Research Institute.
*
* MLton is released under the GNU General Public License (GPL).
* Please see the file MLton-LICENSE for license information.
*/
#ifndef _PLATFORM_H_
#define _PLATFORM_H_
#include <sys/types.h> // lots of includes depend on this
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <grp.h>
#include <math.h>
#include <netdb.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <netinet/udp.h>
#include <pwd.h>
#include <signal.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/poll.h>
#include <sys/resource.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/times.h>
#include <sys/un.h>
#include <sys/utsname.h>
#include <sys/wait.h>
#include <syslog.h>
#include <termios.h>
#include <time.h>
#include <unistd.h>
#include <utime.h>
#if (defined (__CYGWIN__))
#include "platform/cygwin.h"
#elif (defined (__FreeBSD__))
#include "platform/freebsd.h"
#elif (defined (__linux__))
#include "platform/linux.h"
#elif (defined (__MINGW32__))
#include "platform/mingw.h"
#elif (defined (__NetBSD__))
#include "platform/netbsd.h"
#elif (defined (__OpenBSD__))
#include "platform/openbsd.h"
#elif (defined (__sun__))
#include "platform/solaris.h"
#endif
#ifndef HAS_MREMAP
#error HAS_MREMAP not defined
#endif
#ifndef HAS_SIGALTSTACK
#error HAS_SIGALTSTACK not defined
#endif
#ifndef HAS_TIME_PROFILING
#error HAS_TIME_PROFILING not defined
#endif
/* HAS_WEAK is true if the platform supports the weak attribute. */
#ifndef HAS_WEAK
#error HAS_WEAK not defined
#endif
/* On any platform, exactly one of {USE_MMAP, USE_VIRTUAL_ALLOC} should be set
* to true.
*/
#if (!defined (USE_MMAP) && !defined (USE_VIRTUAL_ALLOC))
#error must define USE_MMAP or USE_VIRTUAL_ALLOC
#endif
#if (defined (USE_MMAP) && defined (USE_VIRTUAL_ALLOC))
#error can not define both USE_MMAP and USE_VIRTUAL_ALLOC
#endif
#ifndef SPAWN_MODE
#define SPAWN_MODE 0
#endif
#ifndef ASSERT
#define ASSERT 0
#endif
/* assertion failure routine */
extern void asfail(char *file, int line, char *prop);
/*
* Assertion verifier.
*/
#if ASSERT
#define assert(p) ((p) ? (void)0 : asfail(__FILE__, __LINE__, #p))
#else
#define assert(p) ((void)0)
#endif
#ifndef INT_MIN
#define INT_MIN ((int)0x80000000)
#endif
#ifndef INT_MAX
#define INT_MAX ((int)0x7FFFFFFF)
#endif
#define bool int /* boolean type */
#define uint unsigned int /* short names for unsigned types */
#define ulong unsigned long
#define ullong unsigned long long /* GCC extension */
#define llong long long /* GCC extension */
#define uchar unsigned char
#define ushort unsigned short int
#define not ! /* logical negation operator */
#define and && /* logical conjunction */
#define or || /* logical disjunction */
#ifndef TRUE
#define TRUE (0 == 0)
#endif
#ifndef FALSE
#define FALSE (not TRUE)
#endif
#define loop while (TRUE) /* loop until break */
#define EOS '\0' /* end-of-string char */
#ifndef NULL
#define NULL 0 /* invalid pointer */
#endif
#define NEW(x) x = (typeof(x))(smalloc (sizeof(*x)))
#define ARRAY(a, s) a = (typeof(a))(scalloc (s, sizeof(*a)))
#define string char*
#define unless(p) if (not (p))
#define until(p) while (not (p))
#define cardof(a) (sizeof(a) / sizeof(*(a)))
#define endof(a) ((a) + cardof(a))
#define bitsof(a) (sizeof(a) * 8)
#ifndef max
#define max(a, b) ((a)>(b)?(a):(b))
#endif
#ifndef min
#define min(a, b) ((a)<(b)?(a):(b))
#endif
enum {
DEBUG_SIGNALS = FALSE,
};
#include "types.h"
#include "gc.h"
/* ---------------------------------------------------------------- */
/* Utility libraries */
/* ---------------------------------------------------------------- */
/* issue error message and exit */
extern void die (char *fmt, ...)
__attribute__ ((format(printf, 1, 2)))
__attribute__ ((noreturn));
/* issue error message and exit. Also print strerror(errno). */
extern void diee (char *fmt, ...)
__attribute__ ((format(printf, 1, 2)))
__attribute__ ((noreturn));
/* Display virtual memory to stdout. Used to diagnose memory problems. */
void showMem ();
/*
* totalRam returns the amount of physical memory on the machine.
*/
Word32 totalRam (GC_state s);
string boolToString (bool b);
string intToCommaString (int n);
void *scalloc (size_t nmemb, size_t size);
void sclose (int fd);
void sfclose (FILE *file);
FILE *sfopen (char *fileName, char *mode);
void sfread (void *ptr, size_t size, size_t nmemb, FILE *file);
uint sfreadUint (FILE *file);
void sfwrite (void *ptr, size_t size, size_t nmemb, FILE *file);
void *smalloc (size_t length);
int smkstemp (char *template);
void *smmap (size_t length);
/* A super-safe mmap.
* Allocates a region of memory with dead zones at the high and low ends.
* Any attempt to touch the dead zone (read or write) will cause a
* segmentation fault.
*/
void *ssmmap (size_t length, size_t dead_low, size_t dead_high);
void swrite (int fd, const void *buf, size_t count);
void swriteUint (int fd, uint n);
string uintToCommaString (uint n);
string ullongToCommaString (ullong n);
/* ---------------------------------------------------------------- */
/* MLton libraries */
/* ---------------------------------------------------------------- */
/* ------------------------------------------------- */
/* Array */
/* ------------------------------------------------- */
#define Array_maxLen GC_MAX_ARRAY_LENGTH
Int Array_numElements (Pointer p);
/* ------------------------------------------------- */
/* CommandLine */
/* ------------------------------------------------- */
/* These are initialized by MLton_init. */
extern Int CommandLine_argc;
extern CstringArray CommandLine_argv;
extern Cstring CommandLine_commandName;
/* ------------------------------------------------- */
/* Date */
/* ------------------------------------------------- */
Int Date_Tm_sec();
Int Date_Tm_min();
Int Date_Tm_hour();
Int Date_Tm_mday();
Int Date_Tm_mon();
Int Date_Tm_year();
Int Date_Tm_wday();
Int Date_Tm_yday();
Int Date_Tm_isdst();
void Date_Tm_setSec(Int x);
void Date_Tm_setMin(Int x);
void Date_Tm_setHour(Int x);
void Date_Tm_setMday(Int x);
void Date_Tm_setMon(Int x);
void Date_Tm_setYear(Int x);
void Date_Tm_setWday(Int x);
void Date_Tm_setYday(Int x);
void Date_Tm_setIsdst(Int x);
Cstring Date_ascTime();
void Date_gmTime(Pointer p);
Int Date_localOffset();
void Date_localTime(Pointer p);
Int Date_mkTime();
Int Date_strfTime(Pointer buf, Int n, NullString fmt);
/* ------------------------------------------------- */
/* Debug */
/* ------------------------------------------------- */
void Debug_enter (Pointer name);
void Debug_leave (Pointer name);
/* ------------------------------------------------- */
/* GC */
/* ------------------------------------------------- */
void GC_setMessages (Int b);
void GC_setSummary (Int b);
/* ------------------------------------------------- */
/* IEEEReal */
/* ------------------------------------------------- */
void IEEEReal_setRoundingMode (Int mode);
Int IEEEReal_getRoundingMode ();
/* ------------------------------------------------- */
/* IntInf */
/* ------------------------------------------------- */
/*
* Third header word for bignums and strings.
*/
#define BIGMAGIC GC_objectHeader(WORD_VECTOR_TYPE_INDEX)
#define STRMAGIC GC_objectHeader(STRING_TYPE_INDEX)
/*
* Layout of bignums. Note, the value passed around is a pointer to
* the isneg member.
*/
typedef struct bignum {
uint counter, /* used by GC. */
card, /* one more than the number of limbs */
magic, /* BIGMAGIC */
isneg; /* iff bignum is negative */
ulong limbs[0]; /* big digits, least significant first */
} bignum;
/* All of these routines modify the frontier in gcState. They assume that
* there are bytes bytes free, and allocate an array to store the result
* at the current frontier position.
* Immediately after the bytesArg, they take a labelIndex arg. This is an index
* into the array used for allocation profiling, and the appropriate element
* is incremented by the amount that the function moves the frontier.
*/
Pointer IntInf_add (Pointer lhs, Pointer rhs, uint bytes);
Pointer IntInf_andb (Pointer lhs, Pointer rhs, uint bytes);
Pointer IntInf_arshift (Pointer arg, uint shift, uint bytes);
Pointer IntInf_gcd (Pointer lhs, Pointer rhs, uint bytes);
Pointer IntInf_lshift (Pointer arg, uint shift, uint bytes);
Pointer IntInf_mul (Pointer lhs, Pointer rhs, uint bytes);
Pointer IntInf_neg (Pointer arg, uint bytes);
Pointer IntInf_notb (Pointer arg, uint bytes);
Pointer IntInf_orb (Pointer lhs, Pointer rhs, uint bytes);
Pointer IntInf_quot (Pointer num, Pointer den, uint bytes);
Pointer IntInf_rem (Pointer num, Pointer den, uint bytes);
Pointer IntInf_sub (Pointer lhs, Pointer rhs, uint bytes);
Pointer IntInf_toString (Pointer arg, int base, uint bytes);
Pointer IntInf_xorb (Pointer lhs, Pointer rhs, uint bytes);
Word IntInf_smallMul (Word lhs, Word rhs, Pointer carry);
Int IntInf_compare (Pointer lhs, Pointer rhs);
Int IntInf_equal (Pointer lhs, Pointer rhs);
/* ------------------------------------------------- */
/* Itimer */
/* ------------------------------------------------- */
#define Itimer_prof ITIMER_PROF
#define Itimer_real ITIMER_REAL
#define Itimer_virtual ITIMER_VIRTUAL
void Itimer_set (Int which,
Int interval_tv_sec, Int interval_tv_usec,
Int value_tv_sec, Int value_tv_usec);
/* ------------------------------------------------- */
/* MLton */
/* ------------------------------------------------- */
/* print a bug message and exit (2) */
void MLton_bug (Pointer msg);
Int MLton_errno ();
/* halt the machine */
void MLton_exit (Int status);
Word MLton_random ();
Word MLton_size (Pointer p);
/* ---------------------------------- */
/* MLton.Platform */
/* ---------------------------------- */
#if (defined (__sparc__))
#define MLton_Platform_Arch_host 0
#elif (defined (__i386__))
#define MLton_Platform_Arch_host 1
#else
#error MLton_Platform_Arch_host not defined
#endif
#if (defined (__CYGWIN__))
#define MLton_Platform_OS_host 0
#elif (defined (__FreeBSD__))
#define MLton_Platform_OS_host 1
#elif (defined (__linux__))
#define MLton_Platform_OS_host 2
#elif (defined (__MinGW__))
#define MLton_Platform_OS_host 3
#elif (defined (__NetBSD__))
#define MLton_Platform_OS_host 4
#elif (defined (__OpenBSD__))
#define MLton_Platform_OS_host 5
#elif (defined (__sun__))
#define MLton_Platform_OS_host 6
#else
#error MLton_Platform_OS_host not defined
#endif
/* ---------------------------------- */
/* MLton.Profile */
/* ---------------------------------- */
void MLton_Profile_Data_free (Pointer d);
Pointer MLton_Profile_Data_malloc (void);
void MLton_Profile_Data_write (Pointer data, Word fd);
Pointer MLton_Profile_current (void);
void MLton_Profile_done ();
void MLton_Profile_setCurrent (Pointer d);
/* ---------------------------------- */
/* MLton.Process */
/* ---------------------------------- */
Int MLton_Process_spawne (NullString p, Pointer a, Pointer e);
Int MLton_Process_spawnp (NullString p, Pointer a);
/* ---------------------------------- */
/* MLton.Rlimit */
/* ---------------------------------- */
#define RLIMIT_BOGUS 0xFFFFFFFF
#ifndef RLIMIT_RSS
#define RLIMIT_RSS RLIMIT_BOGUS
#endif
#ifndef RLIMIT_NPROC
#define RLIMIT_NPROC RLIMIT_BOGUS
#endif
#ifndef RLIMIT_MEMLOCK
#define RLIMIT_MEMLOCK RLIMIT_BOGUS
#endif
#define MLton_Rlimit_cpuTime RLIMIT_CPU
#define MLton_Rlimit_coreFileSize RLIMIT_CORE
#define MLton_Rlimit_dataSize RLIMIT_DATA
#define MLton_Rlimit_fileSize RLIMIT_FSIZE
#define MLton_Rlimit_lockedInMemorySize RLIMIT_MEMLOCK
#define MLton_Rlimit_numFiles RLIMIT_NOFILE
#define MLton_Rlimit_numProcesses RLIMIT_NPROC
#define MLton_Rlimit_residentSetSize RLIMIT_RSS
#define MLton_Rlimit_stackSize RLIMIT_STACK
#if (defined (RLIMIT_DATA))
#define MLton_Rlimit_virtualMemorySize RLIMIT_DATA
#elif (defined (RLIMIT_AS))
#define MLton_Rlimit_virtualMemorySize RLIMIT_AS
#else
#error MLton_Rlimit_virtualMemorySize not defined
#endif
#define MLton_Rlimit_infinity RLIM_INFINITY
Int MLton_Rlimit_get (Resource r);
Rlimit MLton_Rlimit_getHard ();
Rlimit MLton_Rlimit_getSoft ();
Int MLton_Rlimit_set (Resource r, Rlimit hard, Rlimit soft);
/* ------------------------------------------------- */
/* OS */
/* ------------------------------------------------- */
#define OS_IO_POLLIN POLLIN
#define OS_IO_POLLPRI POLLPRI
#define OS_IO_POLLOUT POLLOUT
Cstring OS_FileSys_tmpnam ();
Int OS_IO_poll (Int *fds, Word *eventss, Int n, Int timeout, Word *reventss);
/* ------------------------------------------------- */
/* PackReal */
/* ------------------------------------------------- */
Real64 PackReal_subVec (Pointer v, Int offset);
void PackReal_update (Pointer a, Int offset, Real64 r);
/* ------------------------------------------------- */
/* Posix */
/* ------------------------------------------------- */
/* ---------------------------------- */
/* Posix.Error */
/* ---------------------------------- */
void Posix_Error_clearErrno ();
Int Posix_Error_gettErrno ();
Cstring Posix_Error_strerror (Syserror n);
#define Posix_Error_acces EACCES
#define Posix_Error_again EAGAIN
#define Posix_Error_badf EBADF
#ifndef EBADMSG
#define EBADMSG 0
#endif
#define Posix_Error_badmsg EBADMSG
#define Posix_Error_busy EBUSY
#ifndef ECANCELED
#define ECANCELED 0
#endif
#define Posix_Error_canceled ECANCELED
#define Posix_Error_child ECHILD
#define Posix_Error_deadlk EDEADLK
#define Posix_Error_dom EDOM
#define Posix_Error_exist EEXIST
#define Posix_Error_fault EFAULT
#define Posix_Error_fbig EFBIG
#define Posix_Error_inprogress EINPROGRESS
#define Posix_Error_intr EINTR
#define Posix_Error_inval EINVAL
#define Posix_Error_io EIO
#define Posix_Error_isdir EISDIR
#define Posix_Error_loop ELOOP
#define Posix_Error_mfile EMFILE
#define Posix_Error_mlink EMLINK
#define Posix_Error_msgsize EMSGSIZE
#define Posix_Error_nametoolong ENAMETOOLONG
#define Posix_Error_nfile ENFILE
#define Posix_Error_nodev ENODEV
#define Posix_Error_noent ENOENT
#define Posix_Error_noexec ENOEXEC
#define Posix_Error_nolck ENOLCK
#define Posix_Error_nomem ENOMEM
#define Posix_Error_nospc ENOSPC
#define Posix_Error_nosys ENOSYS
#define Posix_Error_notdir ENOTDIR
#define Posix_Error_notempty ENOTEMPTY
#ifndef ENOTSUP
#define ENOTSUP 0
#endif
#define Posix_Error_notsup ENOTSUP
#define Posix_Error_notty ENOTTY
#define Posix_Error_nxio ENXIO
#define Posix_Error_perm EPERM
#define Posix_Error_pipe EPIPE
#define Posix_Error_range ERANGE
#define Posix_Error_rofs EROFS
#define Posix_Error_spipe ESPIPE
#define Posix_Error_srch ESRCH
#define Posix_Error_toobig E2BIG
#define Posix_Error_xdev EXDEV
/* ---------------------------------- */
/* Posix.FileSys */
/* ---------------------------------- */
#define Posix_FileSys_S_ifsock S_IFSOCK
#define Posix_FileSys_S_iflnk S_IFLNK
#define Posix_FileSys_S_ifreg S_IFREG
#define Posix_FileSys_S_ifblk S_IFBLK
#define Posix_FileSys_S_ifdir S_IFDIR
#define Posix_FileSys_S_ifchr S_IFCHR
#define Posix_FileSys_S_ififo S_IFIFO
#ifndef O_BINARY
#define O_BINARY 0
#endif
#ifndef O_TEXT
#define O_TEXT 0
#endif
#define Posix_FileSys_O_append O_APPEND
#define Posix_FileSys_O_binary O_BINARY
#define Posix_FileSys_O_creat O_CREAT
#define Posix_FileSys_O_excl O_EXCL
#define Posix_FileSys_O_noctty O_NOCTTY
#define Posix_FileSys_O_nonblock O_NONBLOCK
#if (defined (O_SYNC))
#define Posix_FileSys_O_sync O_SYNC
#else
#define Posix_FileSys_O_sync 0
#endif
#define Posix_FileSys_O_text O_TEXT
#define Posix_FileSys_O_trunc O_TRUNC
#define Posix_FileSys_o_rdonly O_RDONLY
#define Posix_FileSys_o_wronly O_WRONLY
#define Posix_FileSys_o_rdwr O_RDWR
#define Posix_FileSys_S_irwxu S_IRWXU
#define Posix_FileSys_S_irusr S_IRUSR
#define Posix_FileSys_S_iwusr S_IWUSR
#define Posix_FileSys_S_ixusr S_IXUSR
#define Posix_FileSys_S_irwxg S_IRWXG
#define Posix_FileSys_S_irgrp S_IRGRP
#define Posix_FileSys_S_iwgrp S_IWGRP
#define Posix_FileSys_S_ixgrp S_IXGRP
#define Posix_FileSys_S_irwxo S_IRWXO
#define Posix_FileSys_S_iroth S_IROTH
#define Posix_FileSys_S_iwoth S_IWOTH
#define Posix_FileSys_S_ixoth S_IXOTH
#define Posix_FileSys_S_isuid S_ISUID
#define Posix_FileSys_S_isgid S_ISGID
#define Posix_FileSys_R_OK R_OK
#define Posix_FileSys_W_OK W_OK
#define Posix_FileSys_X_OK X_OK
#define Posix_FileSys_F_OK F_OK
/* used by pathconf and fpathconf */
#define Posix_FileSys_CHOWN_RESTRICTED _PC_CHOWN_RESTRICTED
#define Posix_FileSys_LINK_MAX _PC_LINK_MAX
#define Posix_FileSys_MAX_CANON _PC_MAX_CANON
#define Posix_FileSys_MAX_INPUT _PC_MAX_INPUT
#define Posix_FileSys_NAME_MAX _PC_NAME_MAX
#define Posix_FileSys_NO_TRUNC _PC_NO_TRUNC
#define Posix_FileSys_PATH_MAX _PC_PATH_MAX
#define Posix_FileSys_PIPE_BUF _PC_PIPE_BUF
#define Posix_FileSys_VDISABLE _PC_VDISABLE
#if (defined (_PC_SYNC_IO))
#define Posix_FileSys_SYNC_IO _PC_SYNC_IO
#else
#define Posix_FileSys_SYNC_IO 0
#endif
#if (defined (_PC_ASYNC_IO))
#define Posix_FileSys_ASYNC_IO _PC_ASYNC_IO
#else
#define Posix_FileSys_ASYNC_IO 0
#define Posix_FileSys_PRIO_IO 0
#endif
#if (defined (_PC_PRIO_IO))
#define Posix_FileSys_PRIO_IO _PC_PRIO_IO
#else
#define Posix_FileSys_PRIO_IO 0
#endif
Int Posix_FileSys_Dirstream_closedir (Dirstream d);
Dirstream Posix_FileSys_DirStream_opendir (NullString p);
Cstring Posix_FileSys_Dirstream_readdir (Dirstream d);
void Posix_FileSys_Dirstream_rewinddir (Dirstream p);
Int Posix_FileSys_Stat_fstat (Fd f);
Int Posix_FileSys_Stat_lstat (NullString f);
Int Posix_FileSys_Stat_stat (NullString f);
Word Posix_FileSys_Stat_dev ();
Int Posix_FileSys_Stat_ino ();
Word Posix_FileSys_Stat_mode ();
Int Posix_FileSys_Stat_nlink ();
Word Posix_FileSys_Stat_uid ();
Word Posix_FileSys_Stat_gid ();
Word Posix_FileSys_Stat_rdev ();
Position Posix_FileSys_Stat_size ();
Int Posix_FileSys_Stat_atime ();
Int Posix_FileSys_Stat_mtime ();
Int Posix_FileSys_Stat_ctime ();
void Posix_FileSys_Utimbuf_setActime (Int x);
void Posix_FileSys_Utimbuf_setModTime (Int x);
Int Posix_FileSys_Utimbuf_utime (NullString s);
Int Posix_FileSys_access (NullString f, Word w);
Int Posix_FileSys_chdir (NullString p);
Int Posix_FileSys_chmod (NullString p, Mode m);
Int Posix_FileSys_chown (NullString p, Uid u, Gid g);
Int Posix_FileSys_fchmod (Fd f, Mode m);
Int Posix_FileSys_fchown (Fd f, Uid u, Gid g);
Int Posix_FileSys_fpathconf (Fd f, Int n);
Int Posix_FileSys_ftruncate (Fd f, Position n);
Cstring Posix_FileSys_getcwd (Pointer buf, Size n);
Int Posix_FileSys_link (NullString p1, NullString p2);
Int Posix_FileSys_mkdir (NullString p, Word w);
Int Posix_FileSys_mkfifo (NullString p, Word w);
Int Posix_FileSys_open (NullString p, Word w, Mode m);
Int Posix_FileSys_pathconf (NullString p, Int n);
Int Posix_FileSys_readlink (NullString p, Pointer b, Int);
Int Posix_FileSys_rename (NullString p1, NullString p2);
Int Posix_FileSys_rmdir (NullString p);
Int Posix_FileSys_symlink (NullString p1, NullString p2);
Word Posix_FileSys_umask (Word w);
Word Posix_FileSys_unlink (NullString p);
Bool Posix_FileSys_ST_isDir (Word w);
Bool Posix_FileSys_ST_isChr (Word w);
Bool Posix_FileSys_ST_isBlk (Word w);
Bool Posix_FileSys_ST_isReg (Word w);
Bool Posix_FileSys_ST_isFIFO (Word w);
Bool Posix_FileSys_ST_isLink (Word w);
Bool Posix_FileSys_ST_isSock (Word w);
/* ---------------------------------- */
/* Posix.IO */
/* ---------------------------------- */
#define Posix_IO_F_DUPFD F_DUPFD
#define Posix_IO_F_GETFD F_GETFD
#define Posix_IO_F_SETFD F_SETFD
#define Posix_IO_F_GETFL F_GETFL
#define Posix_IO_F_SETFL F_SETFL
#define Posix_IO_F_GETLK F_GETLK
#define Posix_IO_F_SETLK F_SETLK
#define Posix_IO_F_RDLCK F_RDLCK
#define Posix_IO_F_WRLCK F_WRLCK
#define Posix_IO_F_UNLCK F_UNLCK
#define Posix_IO_F_SETLKW F_SETLKW
#define Posix_IO_F_GETOWN F_GETOWN
#define Posix_IO_F_SETOWN F_SETOWN
#define Posix_IO_O_ACCMODE O_ACCMODE
#define Posix_IO_SEEK_SET SEEK_SET
#define Posix_IO_SEEK_CUR SEEK_CUR
#define Posix_IO_SEEK_END SEEK_END
#define Posix_IO_FD_cloexec FD_CLOEXEC
Int Posix_IO_FLock_fcntl (Fd f, Int cmd);
Int Posix_IO_FLock_type ();
Int Posix_IO_FLock_whence ();
Position Posix_IO_FLock_start ();
Position Posix_IO_FLock_len ();
Int Posix_IO_FLock_pid ();
void Posix_IO_FLock_setType (Int x);
void Posix_IO_FLock_setWhence (Int x);
void Posix_IO_FLock_setStart (Position x);
void Posix_IO_FLock_setLen (Position x);
void Posix_IO_FLock_setPid (Int x);
Int Posix_IO_close (Fd f);
Fd Posix_IO_dup (Fd f);
Fd Posix_IO_dup2 (Fd f1, Fd f2);
Int Posix_IO_fcntl2 (Fd f, Int i);
Int Posix_IO_fcntl3 (Fd f, Int i, Int j);
Int Posix_IO_fsync (Fd f);
Position Posix_IO_lseek (Fd f, Position i, Int j);
Int Posix_IO_pipe (Pointer fds);
Ssize Posix_IO_read (Fd fd, Pointer b, Int i, Size s);
Ssize Posix_IO_write (Fd fd, Pointer b, Int i, Size s);
/* ---------------------------------- */
/* Posix.ProcEnv */
/* ---------------------------------- */
extern CstringArray Posix_ProcEnv_environ;
/* used by sysconf. */
#define Posix_ProcEnv_2_FORT_DEV _SC_2_FORT_DEV
#define Posix_ProcEnv_2_FORT_RUN _SC_2_FORT_RUN
#define Posix_ProcEnv_2_SW_DEV _SC_2_SW_DEV
#define Posix_ProcEnv_2_VERSION _SC_2_VERSION
#define Posix_ProcEnv_ARG_MAX _SC_ARG_MAX
#define Posix_ProcEnv_BC_BASE_MAX _SC_BC_BASE_MAX
#define Posix_ProcEnv_BC_DIM_MAX _SC_BC_DIM_MAX
#define Posix_ProcEnv_BC_SCALE_MAX _SC_BC_SCALE_MAX
#define Posix_ProcEnv_BC_STRING_MAX _SC_BC_STRING_MAX
#define Posix_ProcEnv_CHILD_MAX _SC_CHILD_MAX
#define Posix_ProcEnv_CLK_TCK _SC_CLK_TCK
#define Posix_ProcEnv_COLL_WEIGHTS_MAX _SC_COLL_WEIGHTS_MAX
#define Posix_ProcEnv_EXPR_NEST_MAX _SC_EXPR_NEST_MAX
#define Posix_ProcEnv_JOB_CONTROL _SC_JOB_CONTROL
#define Posix_ProcEnv_LINE_MAX _SC_LINE_MAX
#define Posix_ProcEnv_NGROUPS_MAX _SC_NGROUPS_MAX
#define Posix_ProcEnv_OPEN_MAX _SC_OPEN_MAX
#define Posix_ProcEnv_RE_DUP_MAX _SC_RE_DUP_MAX
#define Posix_ProcEnv_SAVED_IDS _SC_SAVED_IDS
#define Posix_ProcEnv_STREAM_MAX _SC_STREAM_MAX
#define Posix_ProcEnv_TZNAME_MAX _SC_TZNAME_MAX
#define Posix_ProcEnv_VERSION _SC_VERSION
enum {
Posix_ProcEnv_numgroups = 100,
};
Pid Posix_ProcEnv_getpid ();
Pid Posix_ProcEnv_getppid ();
Uid Posix_ProcEnv_getuid ();
Uid Posix_ProcEnv_geteuid ();
Gid Posix_ProcEnv_getgid ();
Gid Posix_ProcEnv_getegid ();
Int Posix_ProcEnv_setenv (NullString s, NullString v);
Int Posix_ProcEnv_setuid (Uid u);
Int Posix_ProcEnv_setgid (Gid g);
Int Posix_ProcEnv_getgroups (Pointer groups);
Cstring Posix_ProcEnv_getlogin ();
Pid Posix_ProcEnv_getpgrp ();
Pid Posix_ProcEnv_setsid ();
Int Posix_ProcEnv_setpgid (Pid p, Gid g);
Int Posix_ProcEnv_Uname_uname ();
Cstring Posix_ProcEnv_Uname_sysname ();
Cstring Posix_ProcEnv_Uname_nodename ();
Cstring Posix_ProcEnv_Uname_release ();
Cstring Posix_ProcEnv_Uname_version ();
Cstring Posix_ProcEnv_Uname_machine ();
Int Posix_ProcEnv_Tms_utime ();
Int Posix_ProcEnv_Tms_stime ();
Int Posix_ProcEnv_Tms_cutime ();
Int Posix_ProcEnv_Tms_cstime ();
Cstring Posix_ProcEnv_ctermid ();
Cstring Posix_ProcEnv_getenv (NullString s);
Bool Posix_ProcEnv_isatty (Fd f);
Int Posix_ProcEnv_sysconf (Int i);
Int Posix_ProcEnv_times ();
Cstring Posix_ProcEnv_ttyname (Fd f);
/* ---------------------------------- */
/* Posix.Process */
/* ---------------------------------- */
#define Posix_Process_wnohang WNOHANG
#define Posix_Process_W_untraced WUNTRACED
#define Posix_Signal_abrt SIGABRT
#define Posix_Signal_alrm SIGALRM
#define Posix_Signal_bus SIGBUS
#define Posix_Signal_chld SIGCHLD
#define Posix_Signal_cont SIGCONT
#define Posix_Signal_fpe SIGFPE
#define Posix_Signal_hup SIGHUP
#define Posix_Signal_ill SIGILL
#define Posix_Signal_int SIGINT
#define Posix_Signal_kill SIGKILL
#define Posix_Signal_pipe SIGPIPE
#define Posix_Signal_prof SIGPROF
#define Posix_Signal_quit SIGQUIT
#define Posix_Signal_segv SIGSEGV
#define Posix_Signal_stop SIGSTOP
#define Posix_Signal_term SIGTERM
#define Posix_Signal_tstp SIGTSTP
#define Posix_Signal_ttin SIGTTIN
#define Posix_Signal_ttou SIGTTOU
#define Posix_Signal_usr1 SIGUSR1
#define Posix_Signal_usr2 SIGUSR2
#define Posix_Signal_vtalrm SIGVTALRM
Int Posix_Process_alarm (Int i);
Int Posix_Process_exece (NullString path, Pointer args, Pointer env);
Int Posix_Process_execp (NullString file, Pointer args);
void Posix_Process_exit (Int i);
Pid Posix_Process_fork ();
Int Posix_Process_kill (Pid p, Signal s);
Int Posix_Process_pause ();
Int Posix_Process_sleep (Int i);
Pid Posix_Process_waitpid (Pid p, Pointer s, Int i);
Bool Posix_Process_ifExited (Status s);
Int Posix_Process_exitStatus (Status s);
Bool Posix_Process_ifSignaled (Status s);
Signal Posix_Process_termSig (Status s);
Bool Posix_Process_ifStopped (Status s);
Signal Posix_Process_stopSig (Status s);
/* ---------------------------------- */
/* Posix.Signal */
/* ---------------------------------- */
#define Posix_Signal_block SIG_BLOCK
#if (defined (NSIG))
#define Posix_Signal_numSignals NSIG
#elif (defined (_NSIG))
#define Posix_Signal_numSignals _NSIG
#else
#error Posix_Signal_numSignals not defined
#endif
#define Posix_Signal_setmask SIG_SETMASK
#define Posix_Signal_unblock SIG_UNBLOCK
Int Posix_Signal_default (Int signum);
Int Posix_Signal_handle (Int signum);
Int Posix_Signal_ignore (Int signum);
Int Posix_Signal_isDefault (Int signum, Bool *isDef);
Bool Posix_Signal_isPending (Int signum);
Int Posix_Signal_sigaddset (Int signum);
Int Posix_Signal_sigdelset (Int signum);
Int Posix_Signal_sigemptyset ();
Int Posix_Signal_sigfillset ();
Int Posix_Signal_sigprocmask (Int how);
Int Posix_Signal_sigsuspend ();
/* ---------------------------------- */
/* Posix.SysDB */
/* ---------------------------------- */
Cstring Posix_SysDB_Passwd_name ();
Uid Posix_SysDB_Passwd_uid ();
Gid Posix_SysDB_Passwd_gid ();
Cstring Posix_SysDB_Passwd_dir ();
Cstring Posix_SysDB_Passwd_shell ();
Bool Posix_SysDB_getpwnam (Pointer p);
Bool Posix_SysDB_getpwuid (Uid u);
Bool Posix_SysDB_getgrgid (Gid g);
Bool Posix_SysDB_getgrnam (NullString s);
Cstring Posix_SysDB_Group_name ();
Gid Posix_SysDB_Group_gid ();
CstringArray Posix_SysDB_Group_mem ();
/* ---------------------------------- */
/* Posix.TTY */
/* ---------------------------------- */
#define Posix_TTY_b0 B0
#define Posix_TTY_b110 B110
#define Posix_TTY_b1200 B1200
#define Posix_TTY_b134 B134
#define Posix_TTY_b150 B150
#define Posix_TTY_b1800 B1800
#define Posix_TTY_b19200 B19200
#define Posix_TTY_b200 B200
#define Posix_TTY_b2400 B2400
#define Posix_TTY_b300 B300
#define Posix_TTY_b38400 B38400
#define Posix_TTY_b4800 B4800
#define Posix_TTY_b50 B50
#define Posix_TTY_b600 B600
#define Posix_TTY_b75 B75
#define Posix_TTY_b9600 B9600
#define Posix_TTY_V_eof VEOF
#define Posix_TTY_V_eol VEOL
#define Posix_TTY_V_erase VERASE
#define Posix_TTY_V_intr VINTR
#define Posix_TTY_V_kill VKILL
#define Posix_TTY_V_min VMIN
#define Posix_TTY_V_nccs NCCS
#define Posix_TTY_V_quit VQUIT
#define Posix_TTY_V_start VSTART
#define Posix_TTY_V_stop VSTOP
#define Posix_TTY_V_susp VSUSP
#define Posix_TTY_V_time VTIME
#define Posix_TTY_I_brkint BRKINT
#define Posix_TTY_I_icrnl ICRNL
#define Posix_TTY_I_ignbrk IGNBRK
#define Posix_TTY_I_igncr IGNCR
#define Posix_TTY_I_ignpar IGNPAR
#define Posix_TTY_I_inlcr INLCR
#define Posix_TTY_I_inpck INPCK
#define Posix_TTY_I_istrip ISTRIP
#define Posix_TTY_I_ixoff IXOFF
#define Posix_TTY_I_ixon IXON
#define Posix_TTY_I_parmrk PARMRK
#define Posix_TTY_O_opost OPOST
#define Posix_TTY_C_clocal CLOCAL
#define Posix_TTY_C_cread CREAD
#define Posix_TTY_C_cs5 CS5
#define Posix_TTY_C_cs6 CS6
#define Posix_TTY_C_cs7 CS7
#define Posix_TTY_C_cs8 CS8
#define Posix_TTY_C_csize CSIZE
#define Posix_TTY_C_cstopb CSTOPB
#define Posix_TTY_C_hupcl HUPCL
#define Posix_TTY_C_parenb PARENB
#define Posix_TTY_C_parodd PARODD
#define Posix_TTY_L_echo ECHO
#define Posix_TTY_L_echoe ECHOE
#define Posix_TTY_L_echok ECHOK
#define Posix_TTY_L_echonl ECHONL
#define Posix_TTY_L_icanon ICANON
#define Posix_TTY_L_iexten IEXTEN
#define Posix_TTY_L_isig ISIG
#define Posix_TTY_L_noflsh NOFLSH
#define Posix_TTY_L_tostop TOSTOP
#define Posix_TTY_TC_sadrain TCSADRAIN
#define Posix_TTY_TC_saflush TCSAFLUSH
#define Posix_TTY_TC_sanow TCSANOW
#define Posix_TTY_TC_ion TCION
#define Posix_TTY_TC_ioff TCIOFF
#define Posix_TTY_TC_ooff TCOOFF
#define Posix_TTY_TC_oon TCOON
#define Posix_TTY_TC_iflush TCIFLUSH
#define Posix_TTY_TC_ioflush TCIOFLUSH
#define Posix_TTY_TC_oflush TCOFLUSH
Flag Posix_TTY_Termios_iflag ();
Flag Posix_TTY_Termios_oflag ();
Flag Posix_TTY_Termios_cflag ();
Flag Posix_TTY_Termios_lflag ();
Cstring Posix_TTY_Termios_cc ();
Speed Posix_TTY_Termios_cfgetospeed ();
Speed Posix_TTY_Termios_cfgetispeed ();
void Posix_TTY_Termios_setiflag (Flag f);
void Posix_TTY_Termios_setoflag (Flag f);
void Posix_TTY_Termios_setcflag (Flag f);
void Posix_TTY_Termios_setlflag (Flag f);
Int Posix_TTY_Termios_setospeed (Speed s);
Int Posix_TTY_Termios_setispeed (Speed s);
Int Posix_TTY_getattr (Fd f);
Int Posix_TTY_setattr (Fd f, Int i);
Int Posix_TTY_sendbreak (Fd f, Int i);
Int Posix_TTY_drain (Fd f);
Int Posix_TTY_flush (Fd f, Int i);
Int Posix_TTY_flow (Fd f, Int i);
Int Posix_TTY_getpgrp (Fd f);
Int Posix_TTY_setpgrp (Fd f, Pid p);
/* ------------------------------------------------- */
/* Ptrace */
/* ------------------------------------------------- */
Int Ptrace_ptrace2 (Int request, Int pid);
/* data is a word ref */
Int Ptrace_ptrace4 (Int request, Int pid, Word addr, Pointer data);
/* ------------------------------------------------- */
/* Socket */
/* ------------------------------------------------- */
#if (defined (__MSVCRT__))
void MLton_initSockets ();
#else
static inline void MLton_initSockets () {}
#endif
#define NetHostDB_inAddrLen sizeof(struct in_addr)
#define NetHostDB_INADDR_ANY INADDR_ANY
#define Socket_sockAddrLenMax max(sizeof(struct sockaddr), \
max(sizeof(struct sockaddr_un), \
max(sizeof(struct sockaddr_in), \
sizeof(struct sockaddr_in6))))
#define Socket_AF_UNIX PF_UNIX
#define Socket_AF_INET PF_INET
#define Socket_AF_INET6 PF_INET6
#define Socket_AF_UNSPEC PF_UNSPEC
#define Socket_SOCK_STREAM SOCK_STREAM
#define Socket_SOCK_DGRAM SOCK_DGRAM
#define Socket_Ctl_SOL_SOCKET SOL_SOCKET
#define Socket_Ctl_SO_DEBUG SO_DEBUG
#define Socket_Ctl_SO_REUSEADDR SO_REUSEADDR
#define Socket_Ctl_SO_KEEPALIVE SO_KEEPALIVE
#define Socket_Ctl_SO_DONTROUTE SO_DONTROUTE
#define Socket_Ctl_SO_LINGER SO_LINGER
#define Socket_Ctl_SO_BROADCAST SO_BROADCAST
#define Socket_Ctl_SO_OOBINLINE SO_OOBINLINE
#define Socket_Ctl_SO_SNDBUF SO_SNDBUF
#define Socket_Ctl_SO_RCVBUF SO_RCVBUF
#define Socket_Ctl_SO_TYPE SO_TYPE
#define Socket_Ctl_SO_ERROR SO_ERROR
#define Socket_Ctl_FIONBIO FIONBIO
#define Socket_Ctl_FIONREAD FIONREAD
#define Socket_Ctl_SIOCATMARK SIOCATMARK
#define Socket_SHUT_RD SHUT_RD
#define Socket_SHUT_WR SHUT_WR
#define Socket_SHUT_RDWR SHUT_RDWR
#define Socket_MSG_DONTROUTE MSG_DONTROUTE
#define Socket_MSG_DONTWAIT MSG_DONTWAIT
#define Socket_MSG_OOB MSG_OOB
#define Socket_MSG_PEEK MSG_PEEK
#define Socket_INetSock_TCP_SOL_TCP IPPROTO_TCP
#define Socket_INetSock_TCP_SO_NODELAY TCP_NODELAY
/* ------------------------------------------------- */
/* Stdio */
/* ------------------------------------------------- */
void Stdio_print (Pointer s);
Int Stdio_sprintf (Pointer buf, Pointer fmt, Real64 x);
/* ------------------------------------------------- */
/* String */
/* ------------------------------------------------- */
int String_equal (char * s1, char * s2);
/* ------------------------------------------------- */
/* Thread */
/* ------------------------------------------------- */
Thread Thread_current ();
void Thread_finishHandler ();
void Thread_resetSignals ();
Thread Thread_saved ();
void Thread_setHandler (Thread t);
void Thread_startHandler ();
void Thread_switchTo (Thread t, Word ensureBytesFree);
/* ------------------------------------------------- */
/* Time */
/* ------------------------------------------------- */
Int Time_gettimeofday ();
Int Time_sec ();
Int Time_usec ();
/* ------------------------------------------------- */
/* Word8 */
/* ------------------------------------------------- */
Char Word8_arshiftAsm (Char w, Word s);
/* ------------------------------------------------- */
/* Word32 */
/* ------------------------------------------------- */
Word Word32_arshiftAsm (Word w, Word s);
#endif /* _PLATFORM_H_ */
1.1 mlton/runtime/Posix/Error.c
Index: Error.c
===================================================================
#include "platform.h"
void Posix_Error_clearErrno () {
errno = 0;
}
int Posix_Error_getErrno () {
return errno;
}
Cstring Posix_Error_strerror (Syserror n) {
return (Cstring)(strerror (n));
}
1.1 mlton/runtime/Posix/Signal.c
Index: Signal.c
===================================================================
#include "platform.h"
extern struct GC_state gcState;
static void handler (int signum) {
GC_handler (&gcState, signum);
}
enum {
#if (defined (SA_ONSTACK))
SA_FLAGS = SA_ONSTACK,
#else
SA_FLAGS = 0,
#endif
};
Int Posix_Signal_default (Int signum) {
struct sigaction sa;
sigdelset (&gcState.signalsHandled, signum);
memset (&sa, 0, sizeof(sa));
sa.sa_handler = SIG_DFL;
sa.sa_flags = SA_FLAGS;
return sigaction (signum, &sa, NULL);
}
bool Posix_Signal_isGCPending () {
Bool res;
res = gcState.gcSignalIsPending;
if (DEBUG_SIGNALS)
fprintf (stderr, "%s = Posix_Signal_isGCPending ()\n",
boolToString (res));
return res;
}
Bool Posix_Signal_isPending (Int signum) {
return sigismember (&gcState.signalsPending, signum);
}
Int Posix_Signal_handle (Int signum) {
static struct sigaction sa;
sigaddset (&gcState.signalsHandled, signum);
memset (&sa, 0, sizeof(sa));
/* The mask must be full because GC_handler reads and writes
* s->signalsPending (else there is a race condition).
*/
sigfillset (&sa.sa_mask);
sa.sa_handler = handler;
sa.sa_flags = SA_FLAGS;
return sigaction (signum, &sa, NULL);
}
void Posix_Signal_handleGC () {
gcState.handleGCSignal = TRUE;
}
Int Posix_Signal_ignore (Int signum) {
struct sigaction sa;
sigdelset (&gcState.signalsHandled, signum);
memset (&sa, 0, sizeof(sa));
sa.sa_handler = SIG_IGN;
sa.sa_flags = SA_FLAGS;
return sigaction (signum, &sa, NULL);
}
Int Posix_Signal_isDefault (Int signum, Bool *isDef) {
Int res;
struct sigaction sa;
sa.sa_flags = SA_FLAGS;
res = sigaction (signum, NULL, &sa);
*isDef = sa.sa_handler == SIG_DFL;
return res;
}
void Posix_Signal_resetPending () {
if (DEBUG_SIGNALS)
fprintf (stderr, "Posix_Signal_resetPending ()\n");
sigemptyset (&gcState.signalsPending);
gcState.gcSignalIsPending = FALSE;
}
static sigset_t set;
Int Posix_Signal_sigaddset (Int signum) {
return sigaddset (&set, signum);
}
Int Posix_Signal_sigdelset (Int signum) {
return sigdelset (&set, signum);
}
Int Posix_Signal_sigemptyset () {
return sigemptyset (&set);
}
Int Posix_Signal_sigfillset () {
return sigfillset (&set);
}
Int Posix_Signal_sigismember (Int signum) {
return sigismember (&set, signum);
}
Int Posix_Signal_sigprocmask (Int how) {
return sigprocmask (how, &set, &set);
}
void Posix_Signal_suspend () {
int res;
res = sigsuspend (&set);
assert (-1 == res);
}
1.1 mlton/runtime/Posix/TTY.c
Index: TTY.c
===================================================================
#include "platform.h"
static struct termios termios;
Flag Posix_TTY_Termios_iflag () {
return termios.c_iflag;
}
Flag Posix_TTY_Termios_oflag () {
return termios.c_oflag;
}
Flag Posix_TTY_Termios_cflag () {
return termios.c_cflag;
}
Flag Posix_TTY_Termios_lflag () {
return termios.c_lflag;
}
Cstring Posix_TTY_Termios_cc () {
return (Cstring)termios.c_cc;
}
Speed Posix_TTY_Termios_cfgetospeed () {
return cfgetospeed (&termios);
}
Speed Posix_TTY_Termios_cfgetispeed () {
return cfgetispeed (&termios);
}
void Posix_TTY_Termios_setiflag (Flag f) {
termios.c_iflag = f;
}
void Posix_TTY_Termios_setoflag (Flag f) {
termios.c_oflag = f;
}
void Posix_TTY_Termios_setcflag (Flag f) {
termios.c_cflag = f;
}
void Posix_TTY_Termios_setlflag (Flag f) {
termios.c_lflag = f;
}
Int Posix_TTY_Termios_setospeed (Speed s) {
return cfsetospeed (&termios, s);
}
Int Posix_TTY_Termios_setispeed (Speed s) {
return cfsetispeed (&termios, s);
}
Int Posix_TTY_drain (Fd f) {
return tcdrain (f);
}
Int Posix_TTY_flow (Fd f, Int i) {
return tcflow (f, i);
}
Int Posix_TTY_flush (Fd f, Int i) {
return tcflush (f, i);
}
Int Posix_TTY_getattr (Fd f) {
return tcgetattr (f, &termios);
}
Int Posix_TTY_getpgrp (Fd f) {
return tcgetpgrp (f);
}
Int Posix_TTY_sendbreak (Fd f, Int i) {
return tcsendbreak (f, i);
}
Int Posix_TTY_setattr (Fd f, Int i) {
return tcsetattr (f, i, &termios);
}
Int Posix_TTY_setpgrp (Fd f, Pid p) {
return tcsetpgrp (f, p);
}
1.4 +1 -5 mlton/runtime/Posix/FileSys/Stat.c
Index: Stat.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/FileSys/Stat.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Stat.c 18 Dec 2003 06:17:24 -0000 1.3
+++ Stat.c 25 Aug 2004 17:51:11 -0000 1.4
@@ -1,8 +1,4 @@
-#include <sys/stat.h>
-#include <unistd.h>
-#include "mlton-posix.h"
-
-#include <stdio.h>
+#include "platform.h"
static struct stat statbuf;
1.2 +4 -6 mlton/runtime/Posix/FileSys/Utimbuf.c
Index: Utimbuf.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/FileSys/Utimbuf.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Utimbuf.c 18 Jul 2001 05:51:06 -0000 1.1
+++ Utimbuf.c 25 Aug 2004 17:51:11 -0000 1.2
@@ -1,17 +1,15 @@
-#include <sys/types.h>
-#include <utime.h>
-#include "mlton-posix.h"
+#include "platform.h"
static struct utimbuf utimbuf;
-void Posix_FileSys_Utimbuf_setActime(Int i) {
+void Posix_FileSys_Utimbuf_setActime (Int i) {
utimbuf.actime = i;
}
-void Posix_FileSys_Utimbuf_setModTime(Int i) {
+void Posix_FileSys_Utimbuf_setModTime (Int i) {
utimbuf.modtime = i;
}
-Int Posix_FileSys_Utimbuf_utime(NullString s) {
+Int Posix_FileSys_Utimbuf_utime (NullString s) {
return (Int)utime((char *)s, &utimbuf);
}
1.2 +3 -4 mlton/runtime/Posix/FileSys/access.c
Index: access.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/FileSys/access.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- access.c 18 Jul 2001 05:51:06 -0000 1.1
+++ access.c 25 Aug 2004 17:51:11 -0000 1.2
@@ -1,6 +1,5 @@
-#include <unistd.h>
-#include "mlton-posix.h"
+#include "platform.h"
-Int Posix_FileSys_access(NullString f, Word w) {
- return access((char *) f, w);
+Int Posix_FileSys_access (NullString f, Word w) {
+ return access ((char *) f, w);
}
1.2 +1 -2 mlton/runtime/Posix/FileSys/chdir.c
Index: chdir.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/FileSys/chdir.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- chdir.c 18 Jul 2001 05:51:06 -0000 1.1
+++ chdir.c 25 Aug 2004 17:51:11 -0000 1.2
@@ -1,5 +1,4 @@
-#include <unistd.h>
-#include "mlton-posix.h"
+#include "platform.h"
Int Posix_FileSys_chdir(Cpointer p) {
return chdir((char *) p);
1.2 +3 -5 mlton/runtime/Posix/FileSys/chmod.c
Index: chmod.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/FileSys/chmod.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- chmod.c 18 Jul 2001 05:51:06 -0000 1.1
+++ chmod.c 25 Aug 2004 17:51:11 -0000 1.2
@@ -1,7 +1,5 @@
-#include <sys/stat.h>
-#include <sys/types.h>
-#include "mlton-posix.h"
+#include "platform.h"
-Int Posix_FileSys_chmod(NullString p, Mode m) {
- return chmod((char *) p, m);
+Int Posix_FileSys_chmod (NullString p, Mode m) {
+ return chmod ((char *) p, m);
}
1.2 +3 -4 mlton/runtime/Posix/FileSys/chown.c
Index: chown.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/FileSys/chown.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- chown.c 18 Jul 2001 05:51:06 -0000 1.1
+++ chown.c 25 Aug 2004 17:51:11 -0000 1.2
@@ -1,6 +1,5 @@
-#include <unistd.h>
-#include "mlton-posix.h"
+#include "platform.h"
-Int Posix_FileSys_chown(NullString p, Uid u, Gid g) {
- return chown((char *) p, u, g);
+Int Posix_FileSys_chown (NullString p, Uid u, Gid g) {
+ return chown ((char *) p, u, g);
}
1.2 +3 -5 mlton/runtime/Posix/FileSys/fchmod.c
Index: fchmod.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/FileSys/fchmod.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- fchmod.c 18 Jul 2001 05:51:06 -0000 1.1
+++ fchmod.c 25 Aug 2004 17:51:11 -0000 1.2
@@ -1,7 +1,5 @@
-#include <sys/stat.h>
-#include <sys/types.h>
-#include "mlton-posix.h"
+#include "platform.h"
-Int Posix_FileSys_fchmod(Fd f, Mode m) {
- return fchmod(f, m);
+Int Posix_FileSys_fchmod (Fd f, Mode m) {
+ return fchmod (f, m);
}
1.2 +3 -5 mlton/runtime/Posix/FileSys/fchown.c
Index: fchown.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/FileSys/fchown.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- fchown.c 18 Jul 2001 05:51:06 -0000 1.1
+++ fchown.c 25 Aug 2004 17:51:11 -0000 1.2
@@ -1,7 +1,5 @@
-#include <sys/types.h>
-#include <unistd.h>
-#include "mlton-posix.h"
+#include "platform.h"
-Int Posix_FileSys_fchown(Fd f, Uid u, Gid g) {
- return fchown(f, u, g);
+Int Posix_FileSys_fchown (Fd f, Uid u, Gid g) {
+ return fchown (f, u, g);
}
1.2 +3 -4 mlton/runtime/Posix/FileSys/fpathconf.c
Index: fpathconf.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/FileSys/fpathconf.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- fpathconf.c 18 Jul 2001 05:51:06 -0000 1.1
+++ fpathconf.c 25 Aug 2004 17:51:11 -0000 1.2
@@ -1,6 +1,5 @@
-#include <unistd.h>
-#include "mlton-posix.h"
+#include "platform.h"
-Int Posix_FileSys_fpathconf(Fd f, Int n) {
- return fpathconf(f, n);
+Int Posix_FileSys_fpathconf (Fd f, Int n) {
+ return fpathconf (f, n);
}
1.3 +1 -2 mlton/runtime/Posix/FileSys/ftruncate.c
Index: ftruncate.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/FileSys/ftruncate.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ftruncate.c 4 Dec 2003 22:42:10 -0000 1.2
+++ ftruncate.c 25 Aug 2004 17:51:11 -0000 1.3
@@ -1,5 +1,4 @@
-#include <unistd.h>
-#include "mlton-posix.h"
+#include "platform.h"
Int Posix_FileSys_ftruncate (Fd f, Position n) {
return ftruncate (f, n);
1.2 +3 -4 mlton/runtime/Posix/FileSys/getcwd.c
Index: getcwd.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/FileSys/getcwd.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- getcwd.c 18 Jul 2001 05:51:06 -0000 1.1
+++ getcwd.c 25 Aug 2004 17:51:11 -0000 1.2
@@ -1,6 +1,5 @@
-#include <unistd.h>
-#include "mlton-posix.h"
+#include "platform.h"
-Cstring Posix_FileSys_getcwd(Pointer buf, Size n) {
- return (Cstring)(getcwd((buf), (n)));
+Cstring Posix_FileSys_getcwd (Pointer buf, Size n) {
+ return (Cstring)(getcwd (buf, n));
}
1.2 +3 -4 mlton/runtime/Posix/FileSys/link.c
Index: link.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/FileSys/link.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- link.c 18 Jul 2001 05:51:06 -0000 1.1
+++ link.c 25 Aug 2004 17:51:11 -0000 1.2
@@ -1,6 +1,5 @@
-#include <unistd.h>
-#include "mlton-posix.h"
+#include "platform.h"
-Int Posix_FileSys_link(NullString p1, NullString p2) {
- return link((char *) p1, (char *) p2);
+Int Posix_FileSys_link (NullString p1, NullString p2) {
+ return link ((char *) p1, (char *) p2);
}
1.2 +2 -3 mlton/runtime/Posix/FileSys/mkdir.c
Index: mkdir.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/FileSys/mkdir.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- mkdir.c 18 Jul 2001 05:51:06 -0000 1.1
+++ mkdir.c 25 Aug 2004 17:51:11 -0000 1.2
@@ -1,6 +1,5 @@
-#include <sys/stat.h>
-#include "mlton-posix.h"
+#include "platform.h"
-Int Posix_FileSys_mkdir(NullString p, Word w) {
+Int Posix_FileSys_mkdir (NullString p, Word w) {
return mkdir((char *) p, w);
}
1.2 +3 -4 mlton/runtime/Posix/FileSys/mkfifo.c
Index: mkfifo.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/FileSys/mkfifo.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- mkfifo.c 18 Jul 2001 05:51:06 -0000 1.1
+++ mkfifo.c 25 Aug 2004 17:51:11 -0000 1.2
@@ -1,6 +1,5 @@
-#include <sys/stat.h>
-#include "mlton-posix.h"
+#include "platform.h"
-Int Posix_FileSys_mkfifo(NullString p, Word w) {
- return mkfifo((char *) p, w);
+Int Posix_FileSys_mkfifo (NullString p, Word w) {
+ return mkfifo ((char *) p, w);
}
1.12 +1 -5 mlton/runtime/Posix/FileSys/open.c
Index: open.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/FileSys/open.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- open.c 29 Dec 2003 23:56:49 -0000 1.11
+++ open.c 25 Aug 2004 17:51:11 -0000 1.12
@@ -1,8 +1,4 @@
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include "mlton-posix.h"
+#include "platform.h"
enum {
DEBUG = 0,
1.2 +3 -4 mlton/runtime/Posix/FileSys/pathconf.c
Index: pathconf.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/FileSys/pathconf.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- pathconf.c 18 Jul 2001 05:51:06 -0000 1.1
+++ pathconf.c 25 Aug 2004 17:51:11 -0000 1.2
@@ -1,6 +1,5 @@
-#include <unistd.h>
-#include "mlton-posix.h"
+#include "platform.h"
-Int Posix_FileSys_pathconf(NullString p, Int n) {
- return pathconf((char *) p, n);
+Int Posix_FileSys_pathconf (NullString p, Int n) {
+ return pathconf ((char *)p, n);
}
1.2 +3 -4 mlton/runtime/Posix/FileSys/readlink.c
Index: readlink.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/FileSys/readlink.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- readlink.c 18 Jul 2001 05:51:06 -0000 1.1
+++ readlink.c 25 Aug 2004 17:51:11 -0000 1.2
@@ -1,6 +1,5 @@
-#include <unistd.h>
-#include "mlton-posix.h"
+#include "platform.h"
-Int Posix_FileSys_readlink(NullString p, Pointer b, Int n) {
- return readlink((char *) p, b, n);
+Int Posix_FileSys_readlink (NullString p, Pointer b, Int n) {
+ return readlink ((char *) p, b, n);
}
1.2 +3 -4 mlton/runtime/Posix/FileSys/rename.c
Index: rename.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/FileSys/rename.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- rename.c 18 Jul 2001 05:51:06 -0000 1.1
+++ rename.c 25 Aug 2004 17:51:11 -0000 1.2
@@ -1,6 +1,5 @@
-#include <stdio.h>
-#include "mlton-posix.h"
+#include "platform.h"
-Int Posix_FileSys_rename(NullString p1, NullString p2) {
- return rename((char *) p1, (char *) p2);
+Int Posix_FileSys_rename (NullString p1, NullString p2) {
+ return rename ((char *) p1, (char *) p2);
}
1.2 +3 -4 mlton/runtime/Posix/FileSys/rmdir.c
Index: rmdir.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/FileSys/rmdir.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- rmdir.c 18 Jul 2001 05:51:06 -0000 1.1
+++ rmdir.c 25 Aug 2004 17:51:11 -0000 1.2
@@ -1,6 +1,5 @@
-#include <unistd.h>
-#include "mlton-posix.h"
+#include "platform.h"
-Int Posix_FileSys_rmdir(NullString p) {
- return rmdir((char *) p);
+Int Posix_FileSys_rmdir (NullString p) {
+ return rmdir ((char *) p);
}
1.2 +3 -4 mlton/runtime/Posix/FileSys/symlink.c
Index: symlink.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/FileSys/symlink.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- symlink.c 18 Jul 2001 05:51:06 -0000 1.1
+++ symlink.c 25 Aug 2004 17:51:11 -0000 1.2
@@ -1,6 +1,5 @@
-#include <unistd.h>
-#include "mlton-posix.h"
+#include "platform.h"
-Int Posix_FileSys_symlink(NullString p1, NullString p2) {
- return symlink((char *) p1, (char *) p2);
+Int Posix_FileSys_symlink (NullString p1, NullString p2) {
+ return symlink ((char *) p1, (char *) p2);
}
1.2 +3 -5 mlton/runtime/Posix/FileSys/umask.c
Index: umask.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/FileSys/umask.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- umask.c 18 Jul 2001 05:51:06 -0000 1.1
+++ umask.c 25 Aug 2004 17:51:11 -0000 1.2
@@ -1,7 +1,5 @@
-#include <sys/types.h>
-#include <sys/stat.h>
-#include "mlton-posix.h"
+#include "platform.h"
-Word Posix_FileSys_umask(Word w) {
- return umask(w);
+Word Posix_FileSys_umask (Word w) {
+ return umask (w);
}
1.2 +3 -4 mlton/runtime/Posix/FileSys/unlink.c
Index: unlink.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/FileSys/unlink.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- unlink.c 18 Jul 2001 05:51:06 -0000 1.1
+++ unlink.c 25 Aug 2004 17:51:11 -0000 1.2
@@ -1,6 +1,5 @@
-#include <unistd.h>
-#include "mlton-posix.h"
+#include "platform.h"
-Word Posix_FileSys_unlink(NullString p) {
- return unlink((char *) p);
+Word Posix_FileSys_unlink (NullString p) {
+ return unlink ((char *) p);
}
1.1 mlton/runtime/Posix/FileSys/Dirstream.c
Index: Dirstream.c
===================================================================
#include "platform.h"
Int Posix_FileSys_Dirstream_closedir (Cpointer p) {
return (Int)(closedir ((DIR *) p));
}
Cpointer Posix_FileSys_Dirstream_opendir (Cpointer p) {
return (Cpointer)(opendir ((char *) p));
}
Cstring Posix_FileSys_Dirstream_readdir (Cpointer d) {
struct dirent *e;
e = readdir ((DIR *) d);
return (Cstring)((NULL == e) ? NULL : e->d_name);
}
void Posix_FileSys_Dirstream_rewinddir (Cpointer p) {
rewinddir ((DIR *) p);
}
1.1 mlton/runtime/Posix/FileSys/ST.c
Index: ST.c
===================================================================
#include "platform.h"
Bool Posix_FileSys_ST_isBlk (Word w) {
return S_ISBLK(w);
}
Bool Posix_FileSys_ST_isChr (Word w) {
return S_ISCHR (w);
}
Bool Posix_FileSys_ST_isDir (Word w) {
return S_ISDIR (w);
}
Bool Posix_FileSys_ST_isFIFO (Word w) {
return S_ISFIFO (w);
}
Bool Posix_FileSys_ST_isLink (Word w) {
return S_ISLNK (w);
}
Bool Posix_FileSys_ST_isReg (Word w) {
return S_ISREG (w);
}
Bool Posix_FileSys_ST_isSock (Word w) {
return S_ISSOCK (w);
}
1.5 +1 -3 mlton/runtime/Posix/IO/FLock.c
Index: FLock.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/IO/FLock.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- FLock.c 4 Dec 2003 22:42:10 -0000 1.4
+++ FLock.c 25 Aug 2004 17:51:12 -0000 1.5
@@ -1,6 +1,4 @@
-#include <unistd.h>
-#include <fcntl.h>
-#include "mlton-posix.h"
+#include "platform.h"
static struct flock s_flock;
1.3 +1 -2 mlton/runtime/Posix/IO/close.c
Index: close.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/IO/close.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- close.c 12 May 2003 19:47:04 -0000 1.2
+++ close.c 25 Aug 2004 17:51:12 -0000 1.3
@@ -1,5 +1,4 @@
-#include <unistd.h>
-#include "mlton-posix.h"
+#include "platform.h"
Int Posix_IO_close (Fd f) {
return close (f);
1.3 +1 -2 mlton/runtime/Posix/IO/dup.c
Index: dup.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/IO/dup.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- dup.c 12 May 2003 19:47:04 -0000 1.2
+++ dup.c 25 Aug 2004 17:51:12 -0000 1.3
@@ -1,5 +1,4 @@
-#include <unistd.h>
-#include "mlton-posix.h"
+#include "platform.h"
Fd Posix_IO_dup (Fd f) {
return dup( f);
1.3 +1 -2 mlton/runtime/Posix/IO/dup2.c
Index: dup2.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/IO/dup2.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- dup2.c 12 May 2003 19:47:04 -0000 1.2
+++ dup2.c 25 Aug 2004 17:51:12 -0000 1.3
@@ -1,5 +1,4 @@
-#include <unistd.h>
-#include "mlton-posix.h"
+#include "platform.h"
Fd Posix_IO_dup2 (Fd f1, Fd f2) {
return dup2 (f1, f2);
1.3 +1 -2 mlton/runtime/Posix/IO/fcntl2.c
Index: fcntl2.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/IO/fcntl2.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- fcntl2.c 12 May 2003 19:47:04 -0000 1.2
+++ fcntl2.c 25 Aug 2004 17:51:12 -0000 1.3
@@ -1,5 +1,4 @@
-#include <fcntl.h>
-#include "mlton-posix.h"
+#include "platform.h"
Int Posix_IO_fcntl2 (Fd f, Int i) {
return fcntl (f, i);
1.3 +1 -2 mlton/runtime/Posix/IO/fcntl3.c
Index: fcntl3.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/IO/fcntl3.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- fcntl3.c 12 May 2003 19:47:04 -0000 1.2
+++ fcntl3.c 25 Aug 2004 17:51:12 -0000 1.3
@@ -1,5 +1,4 @@
-#include <fcntl.h>
-#include "mlton-posix.h"
+#include "platform.h"
Int Posix_IO_fcntl3 (Fd f, Int i, Int j) {
return fcntl (f, i, j);
1.3 +1 -2 mlton/runtime/Posix/IO/fsync.c
Index: fsync.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/IO/fsync.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- fsync.c 12 May 2003 19:47:04 -0000 1.2
+++ fsync.c 25 Aug 2004 17:51:12 -0000 1.3
@@ -1,5 +1,4 @@
-#include <unistd.h>
-#include "mlton-posix.h"
+#include "platform.h"
Int Posix_IO_fsync (Fd f) {
return fsync (f);
1.4 +1 -3 mlton/runtime/Posix/IO/lseek.c
Index: lseek.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/IO/lseek.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- lseek.c 4 Dec 2003 22:42:10 -0000 1.3
+++ lseek.c 25 Aug 2004 17:51:12 -0000 1.4
@@ -1,6 +1,4 @@
-#include <sys/types.h>
-#include <unistd.h>
-#include "mlton-posix.h"
+#include "platform.h"
Position Posix_IO_lseek (Fd f, Position i, Int j) {
return lseek (f, i, j);
1.3 +1 -2 mlton/runtime/Posix/IO/pipe.c
Index: pipe.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/IO/pipe.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- pipe.c 12 May 2003 19:47:04 -0000 1.2
+++ pipe.c 25 Aug 2004 17:51:12 -0000 1.3
@@ -1,5 +1,4 @@
-#include <unistd.h>
-#include "mlton-posix.h"
+#include "platform.h"
Int Posix_IO_pipe (Pointer fds) {
return pipe ((int *) fds);
1.3 +1 -2 mlton/runtime/Posix/IO/read.c
Index: read.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/IO/read.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- read.c 12 May 2003 19:47:04 -0000 1.2
+++ read.c 25 Aug 2004 17:51:12 -0000 1.3
@@ -1,5 +1,4 @@
-#include <unistd.h>
-#include "mlton-posix.h"
+#include "platform.h"
Ssize Posix_IO_read (Fd fd, Pointer b, Int i, Size s) {
return (Ssize)(read (fd, (void *) ((char *) b + i), s));
1.4 +1 -2 mlton/runtime/Posix/IO/write.c
Index: write.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/IO/write.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- write.c 12 May 2003 19:47:04 -0000 1.3
+++ write.c 25 Aug 2004 17:51:12 -0000 1.4
@@ -1,5 +1,4 @@
-#include <unistd.h>
-#include "mlton-posix.h"
+#include "platform.h"
Ssize Posix_IO_write (Fd fd, Pointer b, Int i, Size s) {
1.2 +1 -2 mlton/runtime/Posix/ProcEnv/Tms.c
Index: Tms.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/ProcEnv/Tms.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Tms.c 18 Jul 2001 05:51:06 -0000 1.1
+++ Tms.c 25 Aug 2004 17:51:13 -0000 1.2
@@ -1,5 +1,4 @@
-#include <sys/times.h>
-#include "mlton-posix.h"
+#include "platform.h"
static struct tms tms;
1.4 +8 -10 mlton/runtime/Posix/ProcEnv/Uname.c
Index: Uname.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/ProcEnv/Uname.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Uname.c 18 Nov 2003 23:43:15 -0000 1.3
+++ Uname.c 25 Aug 2004 17:51:13 -0000 1.4
@@ -1,6 +1,4 @@
-#include <stdio.h>
-#include <sys/utsname.h>
-#include "mlton-posix.h"
+#include "platform.h"
enum {
DEBUG = 0,
@@ -8,32 +6,32 @@
static struct utsname utsname;
-Int Posix_ProcEnv_Uname_uname() {
+Int Posix_ProcEnv_Uname_uname () {
Int res;
- res = uname(&utsname);
+ res = uname (&utsname);
if (DEBUG)
fprintf (stderr, "%d = Posix_ProcEnv_Uname_uname ()\n",
(int)res);
return res;
}
-Cstring Posix_ProcEnv_Uname_sysname() {
+Cstring Posix_ProcEnv_Uname_sysname () {
return (Cstring)utsname.sysname;
}
-Cstring Posix_ProcEnv_Uname_nodename() {
+Cstring Posix_ProcEnv_Uname_nodename () {
return (Cstring)utsname.nodename;
}
-Cstring Posix_ProcEnv_Uname_release() {
+Cstring Posix_ProcEnv_Uname_release () {
return (Cstring)utsname.release;
}
-Cstring Posix_ProcEnv_Uname_version() {
+Cstring Posix_ProcEnv_Uname_version () {
return (Cstring)utsname.version;
}
-Cstring Posix_ProcEnv_Uname_machine() {
+Cstring Posix_ProcEnv_Uname_machine () {
return (Cstring)utsname.machine;
}
1.2 +1 -1 mlton/runtime/Posix/ProcEnv/environ.c
Index: environ.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/ProcEnv/environ.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- environ.c 18 Jul 2001 05:51:06 -0000 1.1
+++ environ.c 25 Aug 2004 17:51:13 -0000 1.2
@@ -1,4 +1,4 @@
-#include "mlton-posix.h"
+#include "platform.h"
CstringArray Posix_ProcEnv_environ;
1.2 +1 -2 mlton/runtime/Posix/ProcEnv/getenv.c
Index: getenv.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/ProcEnv/getenv.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- getenv.c 18 Jul 2001 05:51:06 -0000 1.1
+++ getenv.c 25 Aug 2004 17:51:13 -0000 1.2
@@ -1,5 +1,4 @@
-#include <stdlib.h>
-#include "mlton-posix.h"
+#include "platform.h"
Cstring Posix_ProcEnv_getenv(NullString s) {
return (Cstring)getenv((char *)s);
1.3 +1 -4 mlton/runtime/Posix/ProcEnv/getgroups.c
Index: getgroups.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/ProcEnv/getgroups.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- getgroups.c 10 Apr 2003 02:03:11 -0000 1.2
+++ getgroups.c 25 Aug 2004 17:51:13 -0000 1.3
@@ -1,7 +1,4 @@
-#include <sys/types.h>
-#include <unistd.h>
-#include "mlton-posix.h"
-#include "posix-constants.h"
+#include "platform.h"
/* Right now this is messy because MLton has no way of dealing with unsigned
* shorts (i.e. gid_t).
1.2 +3 -4 mlton/runtime/Posix/ProcEnv/getlogin.c
Index: getlogin.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/ProcEnv/getlogin.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- getlogin.c 18 Jul 2001 05:51:06 -0000 1.1
+++ getlogin.c 25 Aug 2004 17:51:13 -0000 1.2
@@ -1,6 +1,5 @@
-#include <unistd.h>
-#include "mlton-posix.h"
+#include "platform.h"
-Cstring Posix_ProcEnv_getlogin() {
- return (Cstring)(getlogin());
+Cstring Posix_ProcEnv_getlogin () {
+ return (Cstring)(getlogin ());
}
1.2 +3 -4 mlton/runtime/Posix/ProcEnv/getpgrp.c
Index: getpgrp.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/ProcEnv/getpgrp.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- getpgrp.c 18 Jul 2001 05:51:06 -0000 1.1
+++ getpgrp.c 25 Aug 2004 17:51:13 -0000 1.2
@@ -1,6 +1,5 @@
-#include <unistd.h>
-#include "mlton-posix.h"
+#include "platform.h"
-Pid Posix_ProcEnv_getpgrp() {
- return getpgrp();
+Pid Posix_ProcEnv_getpgrp () {
+ return getpgrp ();
}
1.2 +3 -4 mlton/runtime/Posix/ProcEnv/isatty.c
Index: isatty.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/ProcEnv/isatty.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- isatty.c 18 Jul 2001 05:51:06 -0000 1.1
+++ isatty.c 25 Aug 2004 17:51:13 -0000 1.2
@@ -1,6 +1,5 @@
-#include <unistd.h>
-#include "mlton-posix.h"
+#include "platform.h"
-Bool Posix_ProcEnv_isatty(Fd f) {
- return isatty(f);
+Bool Posix_ProcEnv_isatty (Fd f) {
+ return isatty (f);
}
1.5 +1 -27 mlton/runtime/Posix/ProcEnv/setenv.c
Index: setenv.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/ProcEnv/setenv.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- setenv.c 13 Jun 2004 02:34:33 -0000 1.4
+++ setenv.c 25 Aug 2004 17:51:13 -0000 1.5
@@ -1,31 +1,5 @@
-#include <stdlib.h>
-#include "mlton-posix.h"
-
-#if (defined (__sun__))
-
-#include <stdio.h> // for sprintf
-#include <strings.h>
-
-/* This has a space leak, but I don't see how to avoid it, since the
- * specification of putenv is that it uses the memory for its arg.
- */
-
-Int Posix_ProcEnv_setenv (NullString s, NullString v) {
- char *b;
- char *name;
- char *value;
-
- name = (char *)s;
- value = (char *)v;
- b = malloc (strlen (name) + strlen (value) + 2 /* = and \000 */);
- sprintf (b, "%s=%s", name, value);
- return putenv (b);
-}
-
-#else
+#include "platform.h"
Int Posix_ProcEnv_setenv (NullString s, NullString v) {
return setenv ((char *)s, (char *)v, 1);
}
-
-#endif
1.2 +3 -4 mlton/runtime/Posix/ProcEnv/sysconf.c
Index: sysconf.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/ProcEnv/sysconf.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- sysconf.c 18 Jul 2001 05:51:06 -0000 1.1
+++ sysconf.c 25 Aug 2004 17:51:13 -0000 1.2
@@ -1,6 +1,5 @@
-#include <unistd.h>
-#include "mlton-posix.h"
+#include "platform.h"
-Int Posix_ProcEnv_sysconf(Int i) {
- return sysconf(i);
+Int Posix_ProcEnv_sysconf (Int i) {
+ return sysconf (i);
}
1.2 +3 -4 mlton/runtime/Posix/ProcEnv/ttyname.c
Index: ttyname.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/ProcEnv/ttyname.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ttyname.c 18 Jul 2001 05:51:06 -0000 1.1
+++ ttyname.c 25 Aug 2004 17:51:13 -0000 1.2
@@ -1,6 +1,5 @@
-#include <unistd.h>
-#include "mlton-posix.h"
+#include "platform.h"
-Cstring Posix_ProcEnv_ttyname(Fd f) {
- return (Cstring)ttyname(f);
+Cstring Posix_ProcEnv_ttyname (Fd f) {
+ return (Cstring)(ttyname (f));
}
1.1 mlton/runtime/Posix/ProcEnv/ProcEnv.c
Index: ProcEnv.c
===================================================================
#include "platform.h"
Cstring Posix_ProcEnv_ctermid () {
return (Cstring)(ctermid (NULL));
}
Gid Posix_ProcEnv_getegid () {
return getegid ();
}
Uid Posix_ProcEnv_geteuid () {
return geteuid ();
}
Gid Posix_ProcEnv_getgid () {
return getgid ();
}
Pid Posix_ProcEnv_getpid () {
return getpid ();
}
Pid Posix_ProcEnv_getppid () {
return getppid ();
}
Uid Posix_ProcEnv_getuid () {
return getuid ();
}
Int Posix_ProcEnv_setgid (Gid g) {
return setgid (g);
}
Pid Posix_ProcEnv_setsid () {
return setsid ();
}
Int Posix_ProcEnv_setuid (Uid u) {
return setuid (u);
}
1.2 +3 -4 mlton/runtime/Posix/Process/alarm.c
Index: alarm.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/Process/alarm.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- alarm.c 18 Jul 2001 05:51:06 -0000 1.1
+++ alarm.c 25 Aug 2004 17:51:13 -0000 1.2
@@ -1,6 +1,5 @@
-#include <unistd.h>
-#include "mlton-posix.h"
+#include "platform.h"
-Int Posix_Process_alarm(Int i) {
- return alarm(i);
+Int Posix_Process_alarm (Int i) {
+ return alarm (i);
}
1.2 +5 -7 mlton/runtime/Posix/Process/exece.c
Index: exece.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/Process/exece.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- exece.c 18 Jul 2001 05:51:06 -0000 1.1
+++ exece.c 25 Aug 2004 17:51:15 -0000 1.2
@@ -1,8 +1,6 @@
-#include <unistd.h>
-#include "gc.h"
-#include "mlton-posix.h"
+#include "platform.h"
-Int Posix_Process_exece(NullString p, Pointer a, Pointer e) {
+Int Posix_Process_exece (NullString p, Pointer a, Pointer e) {
char *path;
char *asaved;
char *esaved;
@@ -15,13 +13,13 @@
path = (char *) p;
args = (char **) a;
env = (char **) e;
- an = GC_arrayNumElements(a) - 1;
+ an = GC_arrayNumElements (a) - 1;
asaved = args[an];
- en = GC_arrayNumElements(e) - 1;
+ en = GC_arrayNumElements (e) - 1;
esaved = env[en];
args[an] = (char *) NULL;
env[en] = (char *) NULL;
- result = execve(path, args, env);
+ result = execve (path, args, env);
/* exece failed */
args[an] = asaved;
env[en] = esaved;
1.2 +4 -6 mlton/runtime/Posix/Process/execp.c
Index: execp.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/Process/execp.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- execp.c 18 Jul 2001 05:51:06 -0000 1.1
+++ execp.c 25 Aug 2004 17:51:15 -0000 1.2
@@ -1,8 +1,6 @@
-#include <unistd.h>
-#include "gc.h"
-#include "mlton-posix.h"
+#include "platform.h"
-Int Posix_Process_execp(NullString f, Pointer a) {
+Int Posix_Process_execp (NullString f, Pointer a) {
char *file;
char *saved;
char **args;
@@ -11,10 +9,10 @@
file = (char *) f;
args = (char **) a;
- n = GC_arrayNumElements(a) - 1;
+ n = GC_arrayNumElements (a) - 1;
saved = args[n];
args[n] = (char *) NULL;
- result = execvp(file, args);
+ result = execvp (file, args);
/* execp failed */
args[n] = saved;
return result;
1.3 +1 -2 mlton/runtime/Posix/Process/exit.c
Index: exit.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/Process/exit.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- exit.c 23 Jun 2003 04:59:01 -0000 1.2
+++ exit.c 25 Aug 2004 17:51:15 -0000 1.3
@@ -1,5 +1,4 @@
-#include <stdlib.h>
-#include "mlton-posix.h"
+#include "platform.h"
void Posix_Process_exit (Int i) {
exit (i);
1.2 +3 -4 mlton/runtime/Posix/Process/exitStatus.c
Index: exitStatus.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/Process/exitStatus.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- exitStatus.c 18 Jul 2001 05:51:06 -0000 1.1
+++ exitStatus.c 25 Aug 2004 17:51:15 -0000 1.2
@@ -1,6 +1,5 @@
-#include <sys/wait.h>
-#include "mlton-posix.h"
+#include "platform.h"
-Int Posix_Process_exitStatus(Status s) {
- return WEXITSTATUS(s);
+Int Posix_Process_exitStatus (Status s) {
+ return WEXITSTATUS (s);
}
1.5 +3 -4 mlton/runtime/Posix/Process/fork.c
Index: fork.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/Process/fork.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- fork.c 18 Mar 2002 22:40:06 -0000 1.4
+++ fork.c 25 Aug 2004 17:51:15 -0000 1.5
@@ -1,6 +1,5 @@
-#include <unistd.h>
-#include "mlton-posix.h"
+#include "platform.h"
-Pid Posix_Process_fork() {
- return fork();
+Pid Posix_Process_fork () {
+ return fork ();
}
1.3 +3 -4 mlton/runtime/Posix/Process/ifExited.c
Index: ifExited.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/Process/ifExited.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ifExited.c 24 Feb 2002 04:48:29 -0000 1.2
+++ ifExited.c 25 Aug 2004 17:51:15 -0000 1.3
@@ -1,6 +1,5 @@
-#include <sys/wait.h>
-#include "mlton-posix.h"
+#include "platform.h"
-Bool Posix_Process_ifExited(Status s) {
- return WIFEXITED(s);
+Bool Posix_Process_ifExited (Status s) {
+ return WIFEXITED (s);
}
1.3 +3 -4 mlton/runtime/Posix/Process/ifSignaled.c
Index: ifSignaled.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/Process/ifSignaled.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ifSignaled.c 24 Feb 2002 04:48:29 -0000 1.2
+++ ifSignaled.c 25 Aug 2004 17:51:15 -0000 1.3
@@ -1,6 +1,5 @@
-#include <sys/wait.h>
-#include "mlton-posix.h"
+#include "platform.h"
-Bool Posix_Process_ifSignaled(Status s) {
- return WIFSIGNALED(s);
+Bool Posix_Process_ifSignaled (Status s) {
+ return WIFSIGNALED (s);
}
1.3 +3 -4 mlton/runtime/Posix/Process/ifStopped.c
Index: ifStopped.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/Process/ifStopped.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ifStopped.c 24 Feb 2002 04:48:29 -0000 1.2
+++ ifStopped.c 25 Aug 2004 17:51:15 -0000 1.3
@@ -1,6 +1,5 @@
-#include <sys/wait.h>
-#include "mlton-posix.h"
+#include "platform.h"
-Bool Posix_Process_ifStopped(Status s) {
- return WIFSTOPPED(s);
+Bool Posix_Process_ifStopped (Status s) {
+ return WIFSTOPPED (s);
}
1.2 +3 -4 mlton/runtime/Posix/Process/kill.c
Index: kill.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/Process/kill.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- kill.c 18 Jul 2001 05:51:06 -0000 1.1
+++ kill.c 25 Aug 2004 17:51:15 -0000 1.2
@@ -1,6 +1,5 @@
-#include <signal.h>
-#include "mlton-posix.h"
+#include "platform.h"
-Int Posix_Process_kill(Pid p, Signal s) {
- return kill(p, s);
+Int Posix_Process_kill (Pid p, Signal s) {
+ return kill (p, s);
}
1.2 +3 -4 mlton/runtime/Posix/Process/pause.c
Index: pause.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/Process/pause.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- pause.c 18 Jul 2001 05:51:06 -0000 1.1
+++ pause.c 25 Aug 2004 17:51:15 -0000 1.2
@@ -1,6 +1,5 @@
-#include <unistd.h>
-#include "mlton-posix.h"
+#include "platform.h"
-Int Posix_Process_pause() {
- return pause();
+Int Posix_Process_pause () {
+ return pause ();
}
1.3 +1 -2 mlton/runtime/Posix/Process/sleep.c
Index: sleep.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/Process/sleep.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- sleep.c 23 Jun 2003 04:59:01 -0000 1.2
+++ sleep.c 25 Aug 2004 17:51:15 -0000 1.3
@@ -1,5 +1,4 @@
-#include <unistd.h>
-#include "mlton-posix.h"
+#include "platform.h"
Int Posix_Process_sleep (Int i) {
return sleep (i);
1.3 +3 -4 mlton/runtime/Posix/Process/stopSig.c
Index: stopSig.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/Process/stopSig.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- stopSig.c 24 Feb 2002 04:48:29 -0000 1.2
+++ stopSig.c 25 Aug 2004 17:51:15 -0000 1.3
@@ -1,6 +1,5 @@
-#include <sys/wait.h>
-#include "mlton-posix.h"
+#include "platform.h"
-Signal Posix_Process_stopSig(Status s) {
- return WSTOPSIG(s);
+Signal Posix_Process_stopSig (Status s) {
+ return WSTOPSIG (s);
}
1.3 +1 -2 mlton/runtime/Posix/Process/termSig.c
Index: termSig.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/Process/termSig.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- termSig.c 24 Feb 2002 04:48:29 -0000 1.2
+++ termSig.c 25 Aug 2004 17:51:15 -0000 1.3
@@ -1,5 +1,4 @@
-#include <sys/wait.h>
-#include "mlton-posix.h"
+#include "platform.h"
Signal Posix_Process_termSig(Status s) {
return WTERMSIG(s);
1.3 +3 -4 mlton/runtime/Posix/Process/waitpid.c
Index: waitpid.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/Process/waitpid.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- waitpid.c 24 Feb 2002 04:48:29 -0000 1.2
+++ waitpid.c 25 Aug 2004 17:51:15 -0000 1.3
@@ -1,6 +1,5 @@
-#include <sys/wait.h>
-#include "mlton-posix.h"
+#include "platform.h"
-Pid Posix_Process_waitpid(Pid p, Pointer s, Int i) {
- return waitpid(p, (int*)s, i);
+Pid Posix_Process_waitpid (Pid p, Pointer s, Int i) {
+ return waitpid (p, (int*)s, i);
}
1.2 +1 -4 mlton/runtime/Posix/SysDB/Group.c
Index: Group.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/SysDB/Group.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Group.c 18 Jul 2001 05:51:06 -0000 1.1
+++ Group.c 25 Aug 2004 17:51:16 -0000 1.2
@@ -1,7 +1,4 @@
-#include <grp.h>
-#include <sys/types.h>
-#include "mlton-posix.h"
-#include "my-lib.h"
+#include "platform.h"
static struct group *group;
1.2 +1 -4 mlton/runtime/Posix/SysDB/Passwd.c
Index: Passwd.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/SysDB/Passwd.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Passwd.c 18 Jul 2001 05:51:06 -0000 1.1
+++ Passwd.c 25 Aug 2004 17:51:16 -0000 1.2
@@ -1,7 +1,4 @@
-#include <pwd.h>
-#include <sys/types.h>
-#include "mlton-posix.h"
-#include "my-lib.h"
+#include "platform.h"
static struct passwd *passwd;
1.2 +1 -1 mlton/runtime/basis/CommandLine.c
Index: CommandLine.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/basis/CommandLine.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- CommandLine.c 18 Jul 2001 05:51:05 -0000 1.1
+++ CommandLine.c 25 Aug 2004 17:51:16 -0000 1.2
@@ -1,4 +1,4 @@
-#include "mlton-basis.h"
+#include "platform.h"
Int CommandLine_argc;
CstringArray CommandLine_argv;
1.4 +1 -4 mlton/runtime/basis/Date.c
Index: Date.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/basis/Date.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Date.c 16 Nov 2003 01:13:39 -0000 1.3
+++ Date.c 25 Aug 2004 17:51:16 -0000 1.4
@@ -1,7 +1,4 @@
-#include "mlton-basis.h"
-
-#include <stdio.h>
-#include <time.h>
+#include "platform.h"
enum {
DEBUG = 0,
1.2 +1 -3 mlton/runtime/basis/Debug.c
Index: Debug.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/basis/Debug.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Debug.c 18 Jul 2001 05:51:05 -0000 1.1
+++ Debug.c 25 Aug 2004 17:51:16 -0000 1.2
@@ -1,6 +1,4 @@
-#include "mlton-basis.h"
-
-#include <stdio.h>
+#include "platform.h"
enum {
INDENTATION = 1,
1.5 +1 -2 mlton/runtime/basis/IEEEReal.c
Index: IEEEReal.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/basis/IEEEReal.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- IEEEReal.c 24 Jun 2003 20:22:55 -0000 1.4
+++ IEEEReal.c 25 Aug 2004 17:51:16 -0000 1.5
@@ -1,5 +1,4 @@
-#include "mlton-basis.h"
-#include "my-lib.h"
+#include "platform.h"
/* ------------------------------------------------- */
/* IEEEReal */
1.17 +3 -6 mlton/runtime/basis/IntInf.c
Index: IntInf.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/basis/IntInf.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- IntInf.c 17 Mar 2004 06:04:14 -0000 1.16
+++ IntInf.c 25 Aug 2004 17:51:16 -0000 1.17
@@ -6,10 +6,7 @@
* Please see the file MLton-LICENSE for license information.
*/
-#include <stddef.h> /* for offsetof */
-#include <string.h>
-
-#include "IntInf.h"
+#include "platform.h"
enum {
DEBUG_INT_INF = FALSE,
@@ -316,7 +313,7 @@
* Return an integer which compares to 0 as the two intInf args compare
* to each other.
*/
-int IntInf_compare (pointer lhs, pointer rhs) {
+Int IntInf_compare (pointer lhs, pointer rhs) {
__mpz_struct lhsmpz,
rhsmpz;
mp_limb_t lhsspace[2],
@@ -333,7 +330,7 @@
/*
* Check if two IntInf.int's are equal.
*/
-int IntInf_equal (pointer lhs, pointer rhs) {
+Int IntInf_equal (pointer lhs, pointer rhs) {
if (lhs == rhs)
return TRUE;
if (eitherIsSmall (lhs, rhs))
1.4 +1 -3 mlton/runtime/basis/Stdio.c
Index: Stdio.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/basis/Stdio.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Stdio.c 23 Jun 2003 04:59:01 -0000 1.3
+++ Stdio.c 25 Aug 2004 17:51:16 -0000 1.4
@@ -1,6 +1,4 @@
-#include <stdio.h>
-#include "mlton-basis.h"
-#include "my-lib.h"
+#include "platform.h"
void Stdio_print (Pointer s) {
if (0 == Array_numElements (s))
1.14 +1 -3 mlton/runtime/basis/Thread.c
Index: Thread.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/basis/Thread.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- Thread.c 7 Apr 2004 00:47:48 -0000 1.13
+++ Thread.c 25 Aug 2004 17:51:16 -0000 1.14
@@ -1,6 +1,4 @@
-#include "gc.h"
-#include "mlton-basis.h"
-#include "my-lib.h"
+#include "platform.h"
extern struct GC_state gcState;
1.5 +1 -4 mlton/runtime/basis/Time.c
Index: Time.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/basis/Time.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Time.c 18 Nov 2003 23:43:15 -0000 1.4
+++ Time.c 25 Aug 2004 17:51:16 -0000 1.5
@@ -1,7 +1,4 @@
-#include <stdio.h>
-#include <sys/time.h>
-#include <unistd.h>
-#include "mlton-basis.h"
+#include "platform.h"
enum {
DEBUG = 0,
1.1 mlton/runtime/basis/GC.c
Index: GC.c
===================================================================
#include "platform.h"
extern struct GC_state gcState;
void GC_setMessages (Int b) {
gcState.messages = b;
}
void GC_setSummary (Int b) {
gcState.summary = b;
}
1.1 mlton/runtime/basis/PackReal.c
Index: PackReal.c
===================================================================
#include "platform.h"
Real32 PackReal32_subVec (Pointer v, Int offset) {
Real32 r;
char *p = (char*)&r;
char *s = v + offset;
int i;
for (i = 0; i < 4; ++i)
p[i] = s[i];
return r;
}
Real32 PackReal32_subVecRev (Pointer v, Int offset) {
Real32 r;
char *p = (char*)&r;
char *s = v + offset;
int i;
for (i = 0; i < 4; ++i)
p[i] = s[3 - i];
return r;
}
Real64 PackReal64_subVec (Pointer v, Int offset) {
Real64 r;
char *p = (char*)&r;
char *s = v + offset;
int i;
for (i = 0; i < 8; ++i)
p[i] = s[i];
return r;
}
Real64 PackReal64_subVecRev (Pointer v, Int offset) {
Real64 r;
char *p = (char*)&r;
char *s = v + offset;
int i;
for (i = 0; i < 8; ++i)
p[i] = s[7 - i];
return r;
}
void PackReal32_update (Pointer a, Int offset, Real32 r) {
char *p = (char*)&r;
char *s = a + offset;
int i;
for (i = 0; i < 4; ++i) {
s[i] = p[i];
}
}
void PackReal32_updateRev (Pointer a, Int offset, Real32 r) {
char *p = (char*)&r;
char *s = a + offset;
int i;
for (i = 0; i < 4; ++i) {
s[i] = p[3 - i];
}
}
void PackReal64_update (Pointer a, Int offset, Real64 r) {
char *p = (char*)&r;
char *s = a + offset;
int i;
for (i = 0; i < 8; ++i) {
s[i] = p[i];
}
}
void PackReal64_updateRev (Pointer a, Int offset, Real64 r) {
char *p = (char*)&r;
char *s = a + offset;
int i;
for (i = 0; i < 8; ++i) {
s[i] = p[7 - i];
}
}
1.1 mlton/runtime/basis/Ptrace.c
Index: Ptrace.c
===================================================================
#include "platform.h"
Int Ptrace_ptrace2 (Int request, Int pid) {
return ptrace (request, pid, 0, 0);
}
Int Ptrace_ptrace4 (Int request, Int pid, Word addr, Pointer data) {
return ptrace (request, pid, (int) addr, (int) data);
}
1.2 +3 -4 mlton/runtime/basis/Array/numElements.c
Index: numElements.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/basis/Array/numElements.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- numElements.c 18 Jul 2001 05:51:06 -0000 1.1
+++ numElements.c 25 Aug 2004 17:51:16 -0000 1.2
@@ -1,6 +1,5 @@
-#include "gc.h"
-#include "mlton-basis.h"
+#include "platform.h"
-Int Array_numElements(Pointer p) {
- return GC_arrayNumElements(p);
+Int Array_numElements (Pointer p) {
+ return GC_arrayNumElements (p);
}
1.2 +1 -1 mlton/runtime/basis/Int/Word.c
Index: Word.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/basis/Int/Word.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Word.c 1 May 2004 17:39:02 -0000 1.1
+++ Word.c 25 Aug 2004 17:51:17 -0000 1.2
@@ -1,4 +1,4 @@
-#include "libmlton.h"
+#include "platform.h"
/*
* We have to be very careful implementing WordS_quot and WordS_rem using / and %
1.2 +1 -1 mlton/runtime/basis/Int/Word8Array.c
Index: Word8Array.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/basis/Int/Word8Array.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Word8Array.c 29 Aug 2003 00:25:21 -0000 1.1
+++ Word8Array.c 25 Aug 2004 17:51:17 -0000 1.2
@@ -1,4 +1,4 @@
-#include "mlton-basis.h"
+#include "platform.h"
Word32 Word8Array_subWord32Rev (Pointer v, Int offset) {
Word32 w;
1.2 +1 -1 mlton/runtime/basis/Int/Word8Vector.c
Index: Word8Vector.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/basis/Int/Word8Vector.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Word8Vector.c 29 Aug 2003 00:25:21 -0000 1.1
+++ Word8Vector.c 25 Aug 2004 17:51:17 -0000 1.2
@@ -1,4 +1,4 @@
-#include "mlton-basis.h"
+#include "platform.h"
Word32 Word8Vector_subWord32Rev (Pointer v, Int offset) {
Word32 w;
1.2 +5 -7 mlton/runtime/basis/Itimer/set.c
Index: set.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/basis/Itimer/set.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- set.c 18 Jul 2001 05:51:06 -0000 1.1
+++ set.c 25 Aug 2004 17:51:17 -0000 1.2
@@ -1,10 +1,8 @@
-#include <sys/time.h>
-#include "mlton-basis.h"
-#include "my-lib.h"
+#include "platform.h"
-void Itimer_set(Int which,
- Int interval_tv_sec, Int interval_tv_usec,
- Int value_tv_sec, Int value_tv_usec) {
+void Itimer_set (Int which,
+ Int interval_tv_sec, Int interval_tv_usec,
+ Int value_tv_sec, Int value_tv_usec) {
struct itimerval v;
int i;
@@ -12,6 +10,6 @@
v.it_interval.tv_usec = interval_tv_usec;
v.it_value.tv_sec = value_tv_sec;
v.it_value.tv_usec = value_tv_usec;
- i = setitimer(which, &v, (struct itimerval *)NULL);
+ i = setitimer (which, &v, (struct itimerval *)NULL);
assert(i == 0);
}
1.3 +1 -3 mlton/runtime/basis/MLton/allocTooLarge.c
Index: allocTooLarge.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/basis/MLton/allocTooLarge.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- allocTooLarge.c 18 Feb 2002 01:11:32 -0000 1.2
+++ allocTooLarge.c 25 Aug 2004 17:51:17 -0000 1.3
@@ -1,6 +1,4 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include "mlton-basis.h"
+#include "platform.h"
void MLton_allocTooLarge () {
fprintf (stderr, "Out of memory: attempt to allocate more than %d bytes.\n", 0x7FFFFFFF);
1.3 +1 -3 mlton/runtime/basis/MLton/bug.c
Index: bug.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/basis/MLton/bug.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- bug.c 9 Apr 2002 23:30:59 -0000 1.2
+++ bug.c 25 Aug 2004 17:51:17 -0000 1.3
@@ -1,6 +1,4 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include "mlton-basis.h"
+#include "platform.h"
void MLton_bug (Pointer msg) {
fprintf (stderr, "MLton bug: %s.\n%s\n",
1.2 +1 -2 mlton/runtime/basis/MLton/errno.c
Index: errno.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/basis/MLton/errno.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- errno.c 10 Mar 2002 19:14:04 -0000 1.1
+++ errno.c 25 Aug 2004 17:51:17 -0000 1.2
@@ -1,5 +1,4 @@
-#include <errno.h>
-#include "mlton-basis.h"
+#include "platform.h"
Int MLton_errno () {
return errno;
1.4 +1 -2 mlton/runtime/basis/MLton/exit.c
Index: exit.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/basis/MLton/exit.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- exit.c 23 Jun 2003 04:59:01 -0000 1.3
+++ exit.c 25 Aug 2004 17:51:17 -0000 1.4
@@ -1,5 +1,4 @@
-#include "gc.h"
-#include "mlton-basis.h"
+#include "platform.h"
extern struct GC_state gcState;
1.2 +1 -2 mlton/runtime/basis/MLton/gcTime.c
Index: gcTime.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/basis/MLton/gcTime.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- gcTime.c 18 Jul 2001 05:51:06 -0000 1.1
+++ gcTime.c 25 Aug 2004 17:51:17 -0000 1.2
@@ -1,5 +1,4 @@
-#include "gc.h"
-#include "mlton-basis.h"
+#include "platform.h"
extern struct GC_state gcState;
1.11 +1 -5 mlton/runtime/basis/MLton/profile.c
Index: profile.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/basis/MLton/profile.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- profile.c 7 Jul 2003 22:50:29 -0000 1.10
+++ profile.c 25 Aug 2004 17:51:17 -0000 1.11
@@ -1,8 +1,4 @@
-#include <string.h>
-
-#include "gc.h"
-#include "mlton-basis.h"
-#include "my-lib.h"
+#include "platform.h"
enum {
DEBUG_PROFILE = FALSE,
1.2 +7 -16 mlton/runtime/basis/MLton/rlimit.c
Index: rlimit.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/basis/MLton/rlimit.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- rlimit.c 18 Jul 2001 05:51:06 -0000 1.1
+++ rlimit.c 25 Aug 2004 17:51:17 -0000 1.2
@@ -1,30 +1,21 @@
-#include <sys/time.h>
-#include <sys/resource.h>
-#include <unistd.h>
-
-#include "gc.h"
-#include "mlton-basis.h"
+#include "platform.h"
static struct rlimit rlimit;
-Int MLton_Rlimit_get(Resource r)
-{
- return getrlimit(r, &rlimit);
+Int MLton_Rlimit_get (Resource r) {
+ return getrlimit (r, &rlimit);
}
-Rlimit MLton_Rlimit_getHard()
-{
+Rlimit MLton_Rlimit_getHard () {
return rlimit.rlim_max;
}
-Rlimit MLton_Rlimit_getSoft()
-{
+Rlimit MLton_Rlimit_getSoft () {
return rlimit.rlim_cur;
}
-Int MLton_Rlimit_set(Resource r, Rlimit hard, Rlimit soft)
-{
+Int MLton_Rlimit_set (Resource r, Rlimit hard, Rlimit soft) {
rlimit.rlim_max = hard;
rlimit.rlim_cur = soft;
- return setrlimit(r, &rlimit);
+ return setrlimit (r, &rlimit);
}
1.4 +28 -34 mlton/runtime/basis/MLton/rusage.c
Index: rusage.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/basis/MLton/rusage.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- rusage.c 13 Jun 2004 03:55:08 -0000 1.3
+++ rusage.c 25 Aug 2004 17:51:17 -0000 1.4
@@ -1,10 +1,4 @@
-#if (defined (__FreeBSD__) || defined (__OpenBSD__))
-#include <sys/time.h>
-#endif
-#include <sys/resource.h>
-
-#include "gc.h"
-#include "mlton-basis.h"
+#include "platform.h"
extern struct GC_state gcState;
@@ -12,56 +6,56 @@
static struct rusage children;
static struct rusage gc;
-Int MLton_Rusage_self_utime_sec() {
- return self.ru_utime.tv_sec;
+Int MLton_Rusage_self_utime_sec () {
+ return self.ru_utime.tv_sec;
}
-Int MLton_Rusage_self_utime_usec() {
- return self.ru_utime.tv_usec;
+Int MLton_Rusage_self_utime_usec () {
+ return self.ru_utime.tv_usec;
}
-Int MLton_Rusage_self_stime_sec() {
- return self.ru_stime.tv_sec;
+Int MLton_Rusage_self_stime_sec () {
+ return self.ru_stime.tv_sec;
}
-Int MLton_Rusage_self_stime_usec() {
- return self.ru_stime.tv_usec;
+Int MLton_Rusage_self_stime_usec () {
+ return self.ru_stime.tv_usec;
}
-Int MLton_Rusage_children_utime_sec() {
- return children.ru_utime.tv_sec;
+Int MLton_Rusage_children_utime_sec () {
+ return children.ru_utime.tv_sec;
}
-Int MLton_Rusage_children_utime_usec() {
- return children.ru_utime.tv_usec;
+Int MLton_Rusage_children_utime_usec () {
+ return children.ru_utime.tv_usec;
}
-Int MLton_Rusage_children_stime_sec() {
- return children.ru_stime.tv_sec;
+Int MLton_Rusage_children_stime_sec () {
+ return children.ru_stime.tv_sec;
}
-Int MLton_Rusage_children_stime_usec() {
- return children.ru_stime.tv_usec;
+Int MLton_Rusage_children_stime_usec () {
+ return children.ru_stime.tv_usec;
}
-Int MLton_Rusage_gc_utime_sec() {
- return gc.ru_utime.tv_sec;
+Int MLton_Rusage_gc_utime_sec () {
+ return gc.ru_utime.tv_sec;
}
-Int MLton_Rusage_gc_utime_usec() {
- return gc.ru_utime.tv_usec;
+Int MLton_Rusage_gc_utime_usec () {
+ return gc.ru_utime.tv_usec;
}
-Int MLton_Rusage_gc_stime_sec() {
- return gc.ru_stime.tv_sec;
+Int MLton_Rusage_gc_stime_sec () {
+ return gc.ru_stime.tv_sec;
}
-Int MLton_Rusage_gc_stime_usec() {
- return gc.ru_stime.tv_usec;
+Int MLton_Rusage_gc_stime_usec () {
+ return gc.ru_stime.tv_usec;
}
-void MLton_Rusage_ru() {
+void MLton_Rusage_ru () {
gc = gcState.ru_gc;
- fixedGetrusage(RUSAGE_SELF, &self);
- fixedGetrusage(RUSAGE_CHILDREN, &children);
+ fixedGetrusage (RUSAGE_SELF, &self);
+ fixedGetrusage (RUSAGE_CHILDREN, &children);
}
1.2 +1 -2 mlton/runtime/basis/MLton/size.c
Index: size.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/basis/MLton/size.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- size.c 18 Jul 2001 05:51:06 -0000 1.1
+++ size.c 25 Aug 2004 17:51:17 -0000 1.2
@@ -1,5 +1,4 @@
-#include "gc.h"
-#include "mlton-basis.h"
+#include "platform.h"
extern struct GC_state gcState;
1.4 +10 -14 mlton/runtime/basis/MLton/spawne.c
Index: spawne.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/basis/MLton/spawne.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- spawne.c 24 Jun 2003 21:26:11 -0000 1.3
+++ spawne.c 25 Aug 2004 17:51:17 -0000 1.4
@@ -1,17 +1,14 @@
-#if (defined (__CYGWIN__))
-#include <process.h>
-#include "gc.h"
-#include "mlton-basis.h"
+#include "platform.h"
Int MLton_Process_spawne (NullString p, Pointer a, Pointer e) {
- char *path;
- char *asaved;
- char *esaved;
- char **args;
- char **env;
- int an;
- int en;
- int result;
+ char *path;
+ char *asaved;
+ char *esaved;
+ char **args;
+ char **env;
+ int an;
+ int en;
+ int result;
path = (char *) p;
args = (char **) a;
@@ -22,11 +19,10 @@
esaved = env[en];
args[an] = (char *) NULL;
env[en] = (char *) NULL;
- result = spawnve(0, path,
+ result = spawnve (SPAWN_MODE, path,
(const char * const *)args,
(const char * const *)env);
args[an] = asaved;
env[en] = esaved;
return result;
}
-#endif
1.3 +7 -11 mlton/runtime/basis/MLton/spawnp.c
Index: spawnp.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/basis/MLton/spawnp.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- spawnp.c 16 Sep 2002 18:46:26 -0000 1.2
+++ spawnp.c 25 Aug 2004 17:51:17 -0000 1.3
@@ -1,22 +1,18 @@
-#if (defined (__CYGWIN__))
-#include <process.h>
-#include "gc.h"
-#include "mlton-basis.h"
+#include "platform.h"
Int MLton_Process_spawnp (NullString p, Pointer a) {
- char *path;
- char *asaved;
- char **args;
- int an;
- int result;
+ char *path;
+ char *asaved;
+ char **args;
+ int an;
+ int result;
path = (char *) p;
args = (char **) a;
an = GC_arrayNumElements(a) - 1;
asaved = args[an];
args[an] = (char *) NULL;
- result = spawnvp(0, path, (const char * const *)args);
+ result = spawnvp (SPAWN_MODE, path, (const char * const *)args);
args[an] = asaved;
return result;
}
-#endif
1.2 +1 -2 mlton/runtime/basis/MLton/world.c
Index: world.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/basis/MLton/world.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- world.c 26 Mar 2002 17:27:30 -0000 1.1
+++ world.c 25 Aug 2004 17:51:17 -0000 1.2
@@ -1,5 +1,4 @@
-#include "gc.h"
-#include "mlton-basis.h"
+#include "platform.h"
extern struct GC_state gcState;
1.2 +9 -13 mlton/runtime/basis/Net/Net.c
Index: Net.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/basis/Net/Net.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Net.c 29 Dec 2002 01:23:00 -0000 1.1
+++ Net.c 25 Aug 2004 17:51:17 -0000 1.2
@@ -1,21 +1,17 @@
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include "mlton-basis.h"
-#include "my-lib.h"
+#include "platform.h"
-Int Net_htonl(Int i) {
- return htonl(i);
+Int Net_htonl (Int i) {
+ return htonl (i);
}
-Int Net_ntohl(Int i) {
- return ntohl(i);
+Int Net_ntohl (Int i) {
+ return ntohl (i);
}
-Int Net_htons(Int i) {
- return htons(i);
+Int Net_htons (Int i) {
+ return htons (i);
}
-Int Net_ntohs(Int i) {
- return ntohs(i);
+Int Net_ntohs (Int i) {
+ return ntohs (i);
}
1.5 +1 -5 mlton/runtime/basis/Net/NetHostDB.c
Index: NetHostDB.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/basis/Net/NetHostDB.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- NetHostDB.c 1 May 2004 20:11:38 -0000 1.4
+++ NetHostDB.c 25 Aug 2004 17:51:18 -0000 1.5
@@ -1,8 +1,4 @@
-#include <unistd.h>
-#include <netdb.h>
-#include <sys/socket.h>
-#include "mlton-basis.h"
-#include "my-lib.h"
+#include "platform.h"
static struct hostent *hostent;
1.2 +1 -3 mlton/runtime/basis/Net/NetProtDB.c
Index: NetProtDB.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/basis/Net/NetProtDB.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- NetProtDB.c 5 Dec 2002 01:25:15 -0000 1.1
+++ NetProtDB.c 25 Aug 2004 17:51:18 -0000 1.2
@@ -1,6 +1,4 @@
-#include <netdb.h>
-#include "mlton-basis.h"
-#include "my-lib.h"
+#include "platform.h"
static struct protoent *protoent;
1.4 +1 -3 mlton/runtime/basis/Net/NetServDB.c
Index: NetServDB.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/basis/Net/NetServDB.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- NetServDB.c 5 Dec 2002 13:35:05 -0000 1.3
+++ NetServDB.c 25 Aug 2004 17:51:18 -0000 1.4
@@ -1,6 +1,4 @@
-#include <netdb.h>
-#include "mlton-basis.h"
-#include "my-lib.h"
+#include "platform.h"
static struct servent *servent;
1.2 +1 -5 mlton/runtime/basis/Net/Socket/INetSock.c
Index: INetSock.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/basis/Net/Socket/INetSock.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- INetSock.c 29 Dec 2002 01:23:00 -0000 1.1
+++ INetSock.c 25 Aug 2004 17:51:18 -0000 1.2
@@ -1,8 +1,4 @@
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include "mlton-basis.h"
-#include "my-lib.h"
+#include "platform.h"
void INetSock_toAddr (Pointer in_addr, Int port, Char* addr, Int *addrlen) {
struct sockaddr_in *sa = (struct sockaddr_in*)addr;
1.2 +1 -5 mlton/runtime/basis/Net/Socket/UnixSock.c
Index: UnixSock.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/basis/Net/Socket/UnixSock.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- UnixSock.c 29 Dec 2002 01:23:00 -0000 1.1
+++ UnixSock.c 25 Aug 2004 17:51:18 -0000 1.2
@@ -1,8 +1,4 @@
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include "mlton-basis.h"
-#include "my-lib.h"
+#include "platform.h"
#define UNIX_PATH_MAX 108
1.3 +91 -4 mlton/runtime/basis/Net/Socket/Socket.c
1.6 +2 -4 mlton/runtime/basis/OS/IO/poll.c
Index: poll.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/basis/OS/IO/poll.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- poll.c 6 Jun 2003 20:36:14 -0000 1.5
+++ poll.c 25 Aug 2004 17:51:19 -0000 1.6
@@ -1,8 +1,6 @@
-#include <sys/poll.h>
-#include "mlton-basis.h"
-#include "mlton-posix.h"
+#include "platform.h"
-Int OS_IO_poll(Fd *fds, Word *eventss, Int n, Int timeout, Word *reventss) {
+Int OS_IO_poll (Fd *fds, Word *eventss, Int n, Int timeout, Word *reventss) {
int i, res;
struct pollfd ufds[n];
1.8 +2 -3 mlton/runtime/basis/Real/class.c
Index: class.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/basis/Real/class.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- class.c 22 Aug 2003 04:08:49 -0000 1.7
+++ class.c 25 Aug 2004 17:51:19 -0000 1.8
@@ -1,9 +1,8 @@
-#include <math.h>
+#include "platform.h"
+
#if (defined __sparc__)
#include <ieeefp.h>
#endif
-#include "mlton-basis.h"
-#include "my-lib.h"
enum {
DEBUG = FALSE,
1.3 +1 -2 mlton/runtime/basis/Real/frexp.c
Index: frexp.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/basis/Real/frexp.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- frexp.c 26 Jul 2003 17:54:19 -0000 1.2
+++ frexp.c 25 Aug 2004 17:51:19 -0000 1.3
@@ -1,5 +1,4 @@
-#include <math.h>
-#include "mlton-basis.h"
+#include "platform.h"
double frexp (double x, int* exp);
1.4 +2 -5 mlton/runtime/basis/Real/gdtoa.c
Index: gdtoa.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/basis/Real/gdtoa.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- gdtoa.c 25 Jul 2003 20:14:48 -0000 1.3
+++ gdtoa.c 25 Aug 2004 17:51:19 -0000 1.4
@@ -1,8 +1,5 @@
-#include <stdio.h>
-#include <gc.h>
-#include "gdtoa.h"
-#include "mlton-basis.h"
-#include "my-lib.h"
+#include "platform.h"
+#include "gdtoa/gdtoa.h"
enum {
DEBUG = FALSE,
1.2 +1 -2 mlton/runtime/basis/Real/modf.c
Index: modf.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/basis/Real/modf.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- modf.c 25 Jul 2003 20:14:48 -0000 1.1
+++ modf.c 25 Aug 2004 17:51:19 -0000 1.2
@@ -1,5 +1,4 @@
-#include <math.h>
-#include "mlton-basis.h"
+#include "platform.h"
Real32 Real32_modf(Real32 x, Real32 *exp) {
Real64 exp_, res;
1.6 +1 -2 mlton/runtime/basis/Real/nextAfter.c
Index: nextAfter.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/basis/Real/nextAfter.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- nextAfter.c 26 Jul 2003 20:16:01 -0000 1.5
+++ nextAfter.c 25 Aug 2004 17:51:19 -0000 1.6
@@ -1,5 +1,4 @@
-#include <math.h>
-#include "mlton-basis.h"
+#include "platform.h"
/* nextafter is a macro, so we must have a C wrapper to work correctly. */
Real64 Real64_nextAfter (Real64 x1, Real64 x2) {
1.4 +1 -3 mlton/runtime/basis/Real/real.c
Index: real.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/basis/Real/real.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- real.c 25 Jul 2003 20:14:48 -0000 1.3
+++ real.c 25 Aug 2004 17:51:19 -0000 1.4
@@ -1,6 +1,4 @@
-#include <math.h>
-#include "basis-constants.h"
-#include "mlton-basis.h"
+#include "platform.h"
Real32 Real32_Math_pi = (Real32)M_PI;
Real32 Real32_Math_e = (Real32)M_E;
1.5 +1 -2 mlton/runtime/basis/Real/signBit.c
Index: signBit.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/basis/Real/signBit.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- signBit.c 3 Sep 2003 22:38:00 -0000 1.4
+++ signBit.c 25 Aug 2004 17:51:19 -0000 1.5
@@ -1,5 +1,4 @@
-#include <math.h>
-#include "mlton-basis.h"
+#include "platform.h"
#if (defined __i386__)
1.2 +2 -5 mlton/runtime/basis/Real/strto.c
Index: strto.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/basis/Real/strto.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- strto.c 25 Jul 2003 20:14:48 -0000 1.1
+++ strto.c 25 Aug 2004 17:51:19 -0000 1.2
@@ -1,8 +1,5 @@
-#include <stdio.h>
-#include <gc.h>
-#include "gdtoa.h"
-#include "mlton-basis.h"
-#include "my-lib.h"
+#include "platform.h"
+#include "gdtoa/gdtoa.h"
Real32 Real32_strto (char *s) {
char *endptr;
1.1 mlton/runtime/platform/cygwin.c
Index: cygwin.c
===================================================================
#include "platform.h"
#include "showMem.win32.c"
#include "totalRam.sysconf.c"
1.1 mlton/runtime/platform/cygwin.h
Index: cygwin.h
===================================================================
#include <limits.h>
#include <process.h>
#include <sys/resource.h>
#include <windows.h>
#include "gmp.h"
#include "ptrace.h"
#define HAS_MREMAP FALSE
#define HAS_SIGALTSTACK FALSE
#define HAS_TIME_PROFILING FALSE
#define HAS_WEAK 0
#define USE_VIRTUAL_ALLOC TRUE
#define _SC_BOGUS 0xFFFFFFFF
#define _SC_2_FORT_DEV _SC_BOGUS
#define _SC_2_FORT_RUN _SC_BOGUS
#define _SC_2_SW_DEV _SC_BOGUS
#define _SC_2_VERSION _SC_BOGUS
#define _SC_BC_BASE_MAX _SC_BOGUS
#define _SC_BC_DIM_MAX _SC_BOGUS
#define _SC_BC_SCALE_MAX _SC_BOGUS
#define _SC_BC_STRING_MAX _SC_BOGUS
#define _SC_COLL_WEIGHTS_MAX _SC_BOGUS
#define _SC_EXPR_NEST_MAX _SC_BOGUS
#define _SC_LINE_MAX _SC_BOGUS
#define _SC_RE_DUP_MAX _SC_BOGUS
#define _SC_STREAM_MAX _SC_BOGUS
#define MSG_DONTWAIT 0
#define PF_INET6 0
struct sockaddr_in6 {};
1.1 mlton/runtime/platform/freebsd.c
Index: freebsd.c
===================================================================
#include "platform.h"
void showMem () {
static char buffer[256];
sprintf (buffer, "/bin/cat /proc/%d/map\n", (int)getpid ());
(void)system (buffer);
}
#include "ssmmap.c"
W32 totalRam (GC_state s) {
int mem, len;
len = sizeof (int);
if (-1 == sysctlbyname ("hw.physmem", &mem, &len, NULL, 0))
diee ("sysctl failed");
return mem;
}
1.1 mlton/runtime/platform/freebsd.h
Index: freebsd.h
===================================================================
#include <limits.h>
#include <sys/ptrace.h>
#include <sys/sysctl.h>
#include <ucontext.h>
/* On FreeBSD and OpenBSD the default gmp.h is installed in /usr/include,
* but that is version 2. We want gmp version 4, which the is installed in
* /usr/local/include, and is ensured to exist because it is required by the
* MLton package.
*/
#include "/usr/local/include/gmp.h"
#include "spawn.h"
#define HAS_MREMAP FALSE
#define HAS_SIGALTSTACK TRUE
#define HAS_TIME_PROFILING TRUE
#define HAS_WEAK 1
#define USE_MMAP TRUE
1.1 mlton/runtime/platform/linux.c
Index: linux.c
===================================================================
#include "platform.h"
#include "showMem.linux.c"
#include "ssmmap.c"
#include "totalRam.sysconf.c"
1.1 mlton/runtime/platform/linux.h
Index: linux.h
===================================================================
#include <gmp.h>
#include <sys/ptrace.h>
#include <sys/sysinfo.h>
#include <ucontext.h>
#include <values.h>
#include "spawn.h"
#define HAS_MREMAP TRUE
#define HAS_SIGALTSTACK TRUE
#define HAS_TIME_PROFILING TRUE
#define HAS_WEAK 1
#define USE_MMAP TRUE
/* We need the value of MREMAP_MAYMOVE, which should come from sys/mman.h, but
* isn't there. It is in linux/mman.h, but we can't #include that here, because
* kernel headers don't mix with system headers. We could create a separate
* file, include the kernel headers there, and define a global. But there
* sometimes seem to be problems including kernel headers, so the easiest thing
* to do is just define MREMAP_MAYMOVE.
*/
#define MREMAP_MAYMOVE 1
1.1 mlton/runtime/platform/mingw.c
Index: mingw.c
===================================================================
#include "platform.h"
int getpagesize (void) {
SYSTEM_INFO sysinfo;
GetSystemInfo(&sysinfo);
return sysinfo.dwPageSize;
}
int mkstemp (char *template) {
char file_path[255];
char file_name[255];
char templ[4];
DWORD size = sizeof(file_path);
if (0 == GetTempPath(size, file_path)
diee ("unable to make temporary file");
strncpy(templ, template, 3);
templ[4] = 0x00;
if (0 == GetTempFileName(file_path, templ, 0, file_name))
diee ("unable to make temporary file");
return _open(file_name, _O_CREAT | _O_RDWR, _S_IREAD | _S_IWRITE);
}
#ifndef __GNUC__
#define EPOCHFILETIME (116444736000000000i64)
#else
#define EPOCHFILETIME (116444736000000000LL)
#endif
/* Based on notes by Wu Yongwei:
* http://mywebpage.netscape.com/yongweiwutime.htm
*/
int gettimeofday (struct timeval *tv, struct timezone *tz) {
FILETIME ft;
LARGE_INTEGER li;
__int64 t;
static bool tzInit = FALSE;
if (tz_init) {
_tzset();
tzInit = TRUE;
}
GetSystemTimeAsFileTime (&ft);
li.LowPart = ft.dwLowDateTime;
li.HighPart = ft.dwHighDateTime;
t = li.QuadPart;
t -= EPOCHFILETIME;
t /= 10;
tv.tv_sec = (long)(t / 1000000);
tv.tv_usec = (long)(t % 1000000);
res = 0;
}
static W32 totalRam (GC_state s) {
MEMORYSTATUS memStat;
memStat.dwLength = sizeof(memStat);
GlobalMemoryStatus(&memStat);
return memStat.dwTotalPhys;
}
/* ------------------------------------------------- */
/* MLton.Rlimit */
/* ------------------------------------------------- */
static int rlimit_init = 0;
static struct rlimit rlimits[RLIM_NLIMITS];
void init_rlimits() {
int lim = 0;
for(lim = 0; lim < RLIM_NLIMITS; ++lim )
{
rlimits[lim].rlim_cur = 0;
rlimits[lim].rlim_max = UINT_MAX;
}
++rlimit_init;
}
int getrlimit (int resource, struct rlimit *rlp) {
int rc = 0;
if( ! rlimit_init ) {
init_rlimits();
}
if( (resource < 0) || (resource >= RLIM_NLIMITS) )
{
rc = EINVAL;
}
*rlp = rlimits[resource];
return rc;
}
int setrlimit(int resource, const struct rlimit *rlp) {
int rc = 0;
if( ! rlimit_init ) {
init_rlimits();
}
if( (resource < 0) || (resource >= RLIM_NLIMITS) )
{
rc = EINVAL;
}
if( rlp->rlim_cur < rlimits[resource].rlim_max ) {
rlimits[resource].rlim_cur = rlp->rlim_cur;
} else {
rc = EINVAL;
}
rlimits[resource].rlim_max = rlp->rlim_max;
return rc;
}
/* ------------------------------------------------- */
/* Posix.FileSys */
/* ------------------------------------------------- */
static void GetWin32FileName (int fd, char* fname) {
HANDLE fh, fhmap;
DWORD fileSize, fileSizeHi;
void* pMem = NULL;
fh = (HANDLE)_get_osfhandle (fd);
fileSize = GetFileSize (fh, &fileSizeHi);
fhmap = CreateFileMapping (fh, NULL, PAGE_READONLY, 0, fileSize, NULL);
if (fhmap) {
pMem = MapViewOfFile (fhmap, FILE_MAP_READ, 0, 0, 1);
if (pMem) {
GetMappedFileNameA (GetCurrentProcess(), pMem, fname, MAX_PATH);
UnmapViewOfFile (pMem);
}
CloseHandle (fhmap);
}
return;
}
int fchmod (int fildes, mode_t mode) {
char fname[MAX_PATH + 1];
GetWin32FileName (filedes, fname);
return _chmod (fname, mode);
}
int lstat (const char *file_name, struct stat *buf) {
/* Win32 doesn't really have links. */
return stat (file_name, buf);
}
/* ------------------------------------------------- */
/* Posix.Process */
/* ------------------------------------------------- */
static UINT_PTR curr_timer = 0;
static int curr_timer_dur = 0;
static LARGE_INTEGER timer_start_val;
VOID CALLBACK alarm_signalled(HWND window, UINT message,
UINT_PTR timer_id, DWORD time)
{
printf("Timer fired\n");
}
/*
* Win32 alarm implementation
*/
int alarm (int secs) {
LARGE_INTEGER timer_end_val, frequency;
int remaining = 0;
long elapse = secs * 1000; /* win32 uses usecs */
/* Unsetting the alarm */
if (secs == 0 && curr_timer == 0) {
return 0;
}
if (curr_timer != 0) {
KillTimer(0, curr_timer);
QueryPerformanceCounter(&timer_end_val);
QueryPerformanceFrequency(&frequency);
if (frequency.QuadPart != 0) {
remaining = curr_timer_dur - ((int)(timer_end_val.QuadPart
- timer_start_val.QuadPart)/frequency.QuadPart);
if (remaining < 0) {
remaining = 0;
}
}
timer_start_val.QuadPart = 0;
curr_timer_dur = 0;
curr_timer = 0;
}
if (secs != 0) {
/* Otherwise, set a timer */
curr_timer = SetTimer(0, 0, elapse, alarm_signalled);
QueryPerformanceCounter(&timer_start_val);
curr_timer_dur = secs;
}
return remaining;
}
pid_t waitpid (pid_t pid, int *status, int options) {
return _cwait (s, p, i);
}
/* ------------------------------------------------- */
/* Signals */
/* ------------------------------------------------- */
int sigismember (sigset_t* set, const int signum) {
if (signum < 0 || signum >= NSIG) {
printf("SIG_ERR: sigismember %d out of range", signum);
return -1;
}
if (*set & SIGTOMASK(signum))
return 1;
return 0;
}
int sigaddset (sigset_t *set, const int signum) {
if (signum < 0 || signum >= NSIG) {
printf("SIG_ERR: sigaddset signal %d out of range", signum);
return -1;
}
*set |= SIGTOMASK (signum);
return 0;
}
int sigdelset (sigset_t *set, const int signum) {
if (signum < 0 || signum >= NSIG) {
printf("SIG_ERR: sigdelset signal %d out of range", signum);
return -1;
}
*set &= ~SIGTOMASK (signum);
return 0;
}
int sigemptyset (sigset_t *set) {
*set = (sigset_t) 0;
return 0;
}
int sigfillset (sigset_t *set) {
*set = ~((sigset_t) 0);
return 0;
}
int sigaction (int signum,
const struct sigaction *newact,
struct sigaction *oldact) {
struct sigaction oa;
if (signum < 0 || signum >= NSIG) {
printf ("SIG_ERR: sigaction signal %d out of range", signum);
return -1;
}
if (newact) {
if (signum == SIGKILL || signum == SIGSTOP) {
//set_errno (EINVAL);
return -1;
}
oa.sa_handler = signal (signum, newact->sa_handler);
}
if (oldact)
oldact->sa_handler = oa.sa_handler;
return 0;
}
int sigprocmask (int how, const sigset_t *set, sigset_t *oldset) {
sigset_t opmask;
if (oldset) {
//*oldset = opmask;
}
if (set) {
sigset_t newmask = opmask;
switch (how) {
case SIG_BLOCK:
/* add set to current mask */
newmask |= *set;
break;
case SIG_UNBLOCK:
/* remove set from current mask */
newmask &= ~*set;
break;
case SIG_SETMASK:
/* just set it */
newmask = *set;
break;
default:
return -1;
}
//(void) set_signal_mask (newmask, opmask);
}
return 0;
}
/* ------------------------------------------------- */
/* Posix.SysDB.Passwd */
/* ------------------------------------------------- */
#define INFO_LEVEL 3
static LPUSER_INFO_3 usrData = NULL;
static struct passwd passwd;
struct passwd *getpwnam (const char *name) {
int res;
unless (NERR_Success ==
NetUserGetInfo (NULL, (LPCWSTR)p, INFO_LEVEL,
(LPBYTE*)&usrData))
return NULL;
passwd->pw_dir = usrData->usri3_home_dir;
passwd->pw_gid = usrData->usri3_primary_group_id;
passwd->pw_name = usrData->usri3_name;
passwd->pw_shell = usrData->usri3_script_path;
passwd->pw_uid = usrData->usri3_user_id;
return &passwd;
}
struct passwd *getpwuid (uid_t uid) {
die ("getpwuid not implemented");
}
/* ------------------------------------------------- */
/* Socket */
/* ------------------------------------------------- */
void MLton_initSockets () {
static Bool isInitialized = FALSE;
WORD version;
WSADATA wsaData;
unless (isInitialized) {
isInitialized = TRUE;
version = MAKEWORD (2,2);
WSAStartup (version, &wsaData);
}
}
1.1 mlton/runtime/platform/mingw.h
Index: mingw.h
===================================================================
#include <io.h>
#include <limits.h>
#include <lm.h>
#include <process.h>
#include <psapi.h>
#include <sys/stat.h>
#include <sys/timeb.h>
#include <sys/types.h>
#include <windows.h>
#include <winsock2.h>
#include <ws2tcpip.h>
#undef max
#include "gmp.h"
#include "resource.h"
#define HAS_MREMAP FALSE
#define HAS_SIGALTSTACK FALSE
#define HAS_WEAK FALSE
#define USE_VIRTUAL_ALLOC TRUE
int getpagesize (void);
struct timeval {
long tv_sec;
long tv_usec;
};
#define POLLIN 1
#define POLLPRI 2
#define POLLOUT 4
#define _PC_CHOWN_RESTRICTED 6
#define _PC_LINK_MAX 0
#define _PC_MAX_CANON 1
#define _PC_MAX_INPUT 2
#define _PC_NAME_MAX 3
#define _PC_NO_TRUNC 7
#define _PC_PATH_MAX 4
#define _PC_PIPE_BUF 5
#define _PC_VDISABLE 8
#define F_DUPFD 0
#define F_GETFD 1
#define F_SETFD 2
#define F_GETFL 3
#define F_SETFL 4
#define F_GETLK 7
#define F_SETLK 8
#define F_RDLCK 1
#define F_WRLCK 2
#define F_UNLCK 3
#define F_SETLKW 9
#define FD_CLOEXEC 1
#define MSG_DONTWAIT 0
#define SHUT_RD SD_RECEIVE
#define SHUT_WR SD_SEND
#define SHUT_RDWR SD_BOTH
/* ------------------------------------------------- */
/* Date */
/* ------------------------------------------------- */
struct timezone {
int tz_minuteswest;
int tz_dsttime;
};
/* ------------------------------------------------- */
/* MLton.Itimer */
/* ------------------------------------------------- */
#define ITIMER_REAL 0 /*generates sigalrm */
#define ITIMER_VIRTUAL 1 /*generates sigvtalrm */
#define ITIMER_VIRT 1 /*generates sigvtalrm */
#define ITIMER_PROF 2 /*generates sigprof */
struct itimerval {
struct timeval it_interval;
struct timeval it_value;
};
int setitimer (int which,
const struct itimerval *value,
struct itimerval *ovalue);
/* ------------------------------------------------- */
/* MLton.Rlimit */
/* ------------------------------------------------- */
#define RLIMIT_CPU 0 /* CPU time in seconds */
#define RLIMIT_FSIZE 1 /* Maximum filesize */
#define RLIMIT_DATA 2 /* max data size */
#define RLIMIT_STACK 3 /* max stack size */
#define RLIMIT_CORE 4 /* max core file size */
#define RLIMIT_NOFILE 5 /* max number of open files */
#define RLIMIT_OFILE RLIMIT_NOFILE /* BSD name */
#define RLIMIT_AS 6 /* address space (virt. memory) limit */
#define RLIMIT_NLIMITS 7 /* upper bound of RLIMIT_* defines */
#define RLIM_NLIMITS RLIMIT_NLIMITS
#define RLIM_INFINITY (0xffffffffUL)
#define RLIM_SAVED_MAX RLIM_INFINITY
#define RLIM_SAVED_CUR RLIM_INFINITY
typedef unsigned long rlim_t;
struct rlimit {
rlim_t rlim_cur;
rlim_t rlim_max;
};
/* ------------------------------------------------- */
/* MLton.Rusage */
/* ------------------------------------------------- */
#define RUSAGE_SELF 0 /* calling process */
#define RUSAGE_CHILDREN -1 /* terminated child processes */
struct rusage {
struct timeval ru_utime;
struct timeval ru_stime;
};
/* ------------------------------------------------- */
/* Posix.Error */
/* ------------------------------------------------- */
#define EINPROGRESS WSAEINPROGRESS
#define EMSGSIZE WSAEMSGSIZE
#define ELOOP WSAELOOP
#define EBADMSG 77
/* ------------------------------------------------- */
/* Posix.FileSys */
/* ------------------------------------------------- */
#define S_IRGRP 0000040
#define S_IROTH 0000004
#define S_IRWXG 0000070
#define S_IRWXO 0000007
#define S_ISGID 0002000
#define S_ISUID 0004000
#define S_IWGRP 0000020
#define S_IWOTH 0000002
#define S_IXGRP 0000010
#define S_IXOTH 0000001
#define O_NOCTTY 0x8000
#define O_NONBLOCK 0x4000
#define S_ISLNK(m) 0
static inline int chmod (const char *path, mode_t mode) {
return _chmod (path, mode);
}
static inline int mkdir (const char *pathname, mode_t mode) {
return _mkdir (pathname, mode);
}
static inline int rmdir (const char *pathname) {
return _rmdir (pathname);
}
static inline mode_t umask (mode_t mask) {
return _umask (mask);
}
static inline int unlink (const char *pathname) {
return _unlink (pathname);
}
int fchmod (int fildes, mode_t mode);
int lstat (const char *file_name, struct stat *buf);
/* ------------------------------------------------- */
/* Posix.IO */
/* ------------------------------------------------- */
int fcntl(int fd, int cmd);
int fcntl(int fd, int cmd, long arg);
int fcntl(int fd, int cmd, struct flock *lock);
int fsync (int fd);
int pipe (int filedes[2]);
struct flock {
off_t l_len;
pid_t l_pid;
off_t l_start;
short l_type;
short l_whence;
};
/* ------------------------------------------------- */
/* Posix.ProcEnv */
/* ------------------------------------------------- */
#define _SC_BOGUS 0xFFFFFFFF
#define _SC_2_FORT_DEV _SC_BOGUS
#define _SC_2_FORT_RUN _SC_BOGUS
#define _SC_2_SW_DEV _SC_BOGUS
#define _SC_2_VERSION _SC_BOGUS
#define _SC_ARG_MAX 0
#define _SC_BC_BASE_MAX _SC_BOGUS
#define _SC_BC_DIM_MAX _SC_BOGUS
#define _SC_BC_SCALE_MAX _SC_BOGUS
#define _SC_BC_STRING_MAX _SC_BOGUS
#define _SC_CHILD_MAX 1
#define _SC_CLK_TCK 2
#define _SC_COLL_WEIGHTS_MAX _SC_BOGUS
#define _SC_EXPR_NEST_MAX _SC_BOGUS
#define _SC_JOB_CONTROL 5
#define _SC_LINE_MAX _SC_BOGUS
#define _SC_NGROUPS_MAX 3
#define _SC_OPEN_MAX 4
#define _SC_RE_DUP_MAX _SC_BOGUS
#define _SC_SAVED_IDS 6
#define _SC_STREAM_MAX _SC_BOGUS
#define _SC_TZNAME_MAX 20
#define _SC_VERSION 7
struct tms { /* WARNING: BOGUS! */
int tms_utime; /* user time */
int tms_stime; /* system time */
int tms_cutime; /* user time, children */
int tms_cstime; /* system time, children */
};
struct utsname {
char machine[20];
char nodename[20];
char release[20];
char sysname[20];
char version[20];
};
int uname (struct utsname *buf);
/* ------------------------------------------------- */
/* Posix.Process */
/* ------------------------------------------------- */
#define SPAWN_MODE _P_NOWAIT
/* A status looks like:
<2 bytes info> <2 bytes code>
<code> == 0, child has exited, info is the exit value
<code> == 1..7e, child has exited, info is the signal number.
<code> == 7f, child has stopped, info was the signal number.
<code> == 80, there was a core dump.
*/
#define WNOHANG 1
#define WUNTRACED 2
#define WIFEXITED(w) (((w) & 0xff) == 0)
#define WIFSIGNALED(w) (((w) & 0x7f) > 0 && (((w) & 0x7f) < 0x7f))
#define WIFSTOPPED(w) (((w) & 0xff) == 0x7f)
#define WEXITSTATUS(w) (((w) >> 8) & 0xff)
#define WTERMSIG(w) ((w) & 0x7f)
#define WSTOPSIG WEXITSTATUS
int alarm (int secs);
pid_t fork (void);
pid_t wait (int *status);
pid_t waitpid (pid_t pid, int *status, int options);
/* ------------------------------------------------- */
/* Posix.Signal */
/* ------------------------------------------------- */
#define SIG_BLOCK 1
#define SIG_SETMASK 0
#define SIG_UNBLOCK 2
#define SIGHUP 1
#define SIGKILL 2
#define SIGPIPE 3
#define SIGQUIT 9
#define SIGALRM 13
#define SIGBUS 14
#define SIGSTOP 16
#define SIGTSTP 18
#define SIGCHLD 20
#define SIGTTIN 21
#define SIGTTOU 22
#define SIGCONT 25
#define SIGUSR1 25
#define SIGUSR2 26
#define SIGVTALRM 26 /* virtual time alarm */
#define SIGPROF 27 /* profiling time alarm */
#define _NSIG 32
typedef void (*_sig_func_ptr)();
struct sigaction {
int sa_flags;
sigset_t sa_mask;
_sig_func_ptr sa_handler;
};
#define SIGTOMASK(sn) (1 << ((sn)-1))
int sigaction (int signum,
const struct sigaction *act,
struct sigaction *oldact);
int sigaddset (sigset_t *set, int signum);
int sigdelset (sigset_t *set, int signum);
int sigemptyset (sigset_t *set);
int sigfillset (sigset_t *set);
int sigismember (const sigset_t *set, int signum);
int sigpending (sigset_t *set);
int sigprocmask (int how, const sigset_t *set, sigset_t *oldset);
int sigsuspend (const sigset_t *mask);
/* ------------------------------------------------- */
/* Posix.SysDB.Passwd */
/* ------------------------------------------------- */
struct passwd {
char *pw_dir; /* home directory */
gid_t pw_gid; /* group id */
char *pw_name; /* user name */
char *pw_shell; /* shell program */
uid_t pw_uid; /* user id */
};
struct passwd *getpwnam (const char *name);
struct passwd *getpwuid (uid_t uid);
/* ------------------------------------------------- */
/* Posix.TTY */
/* ------------------------------------------------- */
#define B0 0x00000
#define B50 0x00001
#define B75 0x00002
#define B110 0x00003
#define B134 0x00004
#define B150 0x00005
#define B200 0x00006
#define B300 0x00007
#define B600 0x00008
#define B1200 0x00009
#define B1800 0x0000a
#define B2400 0x0000b
#define B4800 0x0000c
#define B9600 0x0000d
#define B19200 0x0000e
#define B38400 0x0000f
#define VEOL 2
#define VEOL2 3
#define VEOF 4
#define VERASE 5
#define VINTR 6
#define VKILL 7
#define VLNEXT 8
#define VMIN 9
#define VQUIT 10
#define VREPRINT 11
#define VSTART 12
#define VSTOP 13
#define VSUSP 14
#define VSWTC 15
#define VTIME 16
#define VWERASE 17
#define NCCS 18
#define IGNBRK 0x00001
#define BRKINT 0x00002
#define IGNPAR 0x00004
#define IMAXBEL 0x00008
#define INPCK 0x00010
#define ISTRIP 0x00020
#define INLCR 0x00040
#define IGNCR 0x00080
#define ICRNL 0x00100
#define IXON 0x00400
#define IXOFF 0x01000
#define IUCLC 0x04000
#define IXANY 0x08000
#define PARMRK 0x10000
#define OPOST 0x00001
#define CSIZE 0x00030
#define CS5 0x00000
#define CS6 0x00010
#define CS7 0x00020
#define CS8 0x00030
#define CSTOPB 0x00040
#define CREAD 0x00080
#define PARENB 0x00100
#define PARODD 0x00200
#define HUPCL 0x00400
#define CLOCAL 0x00800
#define CBAUDEX 0x0100f
#define B57600 0x01001
#define B115200 0x01002
#define B128000 0x01003
#define B230400 0x01004
#define B256000 0x01005
#define CRTSXOFF 0x04000
#define CRTSCTS 0x08000
#define ISIG 0x0001
#define ICANON 0x0002
#define ECHO 0x0004
#define ECHOE 0x0008
#define ECHOK 0x0010
#define ECHONL 0x0020
#define NOFLSH 0x0040
#define TOSTOP 0x0080
#define IEXTEN 0x0100
#define FLUSHO 0x0200
#define ECHOKE 0x0400
#define ECHOCTL 0x0800
#define TCOOFF 0
#define TCOON 1
#define TCIOFF 2
#define TCION 3
#define TCIFLUSH 0
#define TCOFLUSH 1
#define TCIOFLUSH 2
#define TCFLSH 3
#define TCSAFLUSH 1
#define TCSANOW 2
#define TCSADRAIN 3
#define TCSADFLUSH 4
/* ------------------------------------------------- */
/* Socket */
/* ------------------------------------------------- */
#define MSG_DONTWAIT 0
#define PF_INET6 0
struct sockaddr_in6 {};
struct sockaddr_un {};
1.1 mlton/runtime/platform/netbsd.c
Index: netbsd.c
===================================================================
#include "platform.h"
#include "showMem.linux.c"
#include "ssmmap.c"
#include "totalRam.sysctl.c"
1.1 mlton/runtime/platform/netbsd.h
Index: netbsd.h
===================================================================
#include <sys/param.h>
#include <sys/sysctl.h>
#include <sys/mman.h>
#include <sys/resource.h>
#include <sys/times.h>
/* On NetBSD, we want gmp to be installed into the pkg tree (which represents
* the FreeBSD ports tree). For now we use the same method as in the FreeBSD
* case, but we note that this should be changed so the makefile provides the
* correct -I flags to the compiler
*/
#include "/usr/pkg/include/gmp.h"
#include "ptrace.h"
#include "spawn.h"
#define HAS_MREMAP FALSE
#define HAS_SIGALTSTACK TRUE
#define HAS_TIME_PROFILING TRUE
#define HAS_WEAK 1
#define USE_MMAP TRUE
1.1 mlton/runtime/platform/openbsd.c
Index: openbsd.c
===================================================================
#include "platform.h"
#include "showMem.linux.c"
#include "ssmmap.c"
#include "totalRam.sysctl.c"
1.1 mlton/runtime/platform/openbsd.h
Index: openbsd.h
===================================================================
/* On FreeBSD and OpenBSD the default gmp.h is installed in /usr/include,
* but that is version 2. We want gmp version 4, which the is installed in
* /usr/local/include, and is ensured to exist because it is required by the
* MLton package.
*/
#include "/usr/local/include/gmp.h"
#include <sys/param.h>
#include <sys/sysctl.h>
#include <sys/mman.h>
#include <sys/resource.h>
#include <sys/times.h>
#include "ptrace.h"
#include "spawn.h"
#define HAS_MREMAP FALSE
#define HAS_SIGALTSTACK TRUE
#define HAS_TIME_PROFILING TRUE
#define HAS_WEAK 1
#define USE_MMAP TRUE
1.1 mlton/runtime/platform/ptrace.h
Index: ptrace.h
===================================================================
int ptrace (int a, int b, int c, int d);
1.1 mlton/runtime/platform/setenv.h
Index: setenv.h
===================================================================
int setenv (const char *name, const char *value, int overwrite);
1.1 mlton/runtime/platform/showMem.linux.c
Index: showMem.linux.c
===================================================================
void showMem () {
static char buffer[256];
sprintf (buffer, "/bin/cat /proc/%d/maps\n", (int)(getpid ()));
system (buffer);
}
1.1 mlton/runtime/platform/showMem.win32.c
Index: showMem.win32.c
===================================================================
static void showMaps () {
MEMORY_BASIC_INFORMATION buf;
LPCVOID lpAddress;
char *state = "<unset>";
char *protect = "<unset>";
for (lpAddress = 0; lpAddress < (LPCVOID)0x80000000; ) {
VirtualQuery (lpAddress, &buf, sizeof (buf));
switch (buf.Protect) {
case PAGE_READONLY:
protect = "PAGE_READONLY";
break;
case PAGE_READWRITE:
protect = "PAGE_READWRITE";
break;
case PAGE_WRITECOPY:
protect = "PAGE_WRITECOPY";
break;
case PAGE_EXECUTE:
protect = "PAGE_EXECUTE";
break;
case PAGE_EXECUTE_READ:
protect = "PAGE_EXECUTE_READ";
break;
case PAGE_EXECUTE_READWRITE:
protect = "PAGE_EXECUTE_READWRITE";
break;
case PAGE_EXECUTE_WRITECOPY:
protect = "PAGE_EXECUTE_WRITECOPY";
break;
case PAGE_GUARD:
protect = "PAGE_GUARD";
break;
case PAGE_NOACCESS:
protect = "PAGE_NOACCESS";
break;
case PAGE_NOCACHE:
protect = "PAGE_NOCACHE";
break;
}
switch (buf.State) {
case MEM_COMMIT:
state = "MEM_COMMIT";
break;
case MEM_FREE:
state = "MEM_FREE";
break;
case MEM_RESERVE:
state = "MEM_RESERVE";
break;
}
fprintf(stderr, "0x%8x %10u %s %s\n",
(uint)buf.BaseAddress,
(uint)buf.RegionSize,
state, protect);
lpAddress += buf.RegionSize;
}
}
void showMem () {
MEMORYSTATUS ms;
ms.dwLength = sizeof (MEMORYSTATUS);
GlobalMemoryStatus (&ms);
fprintf(stderr, "Total Phys. Mem: %ld\nAvail Phys. Mem: %ld\nTotal Page File: %ld\nAvail Page File: %ld\nTotal Virtual: %ld\nAvail Virtual: %ld\n",
ms.dwTotalPhys,
ms.dwAvailPhys,
ms.dwTotalPageFile,
ms.dwAvailPageFile,
ms.dwTotalVirtual,
ms.dwAvailVirtual);
showMaps();
}
1.1 mlton/runtime/platform/solaris.c
Index: solaris.c
===================================================================
#include "platform.h"
/* This implementation of setenv has a space leak, but I don't see how to avoid
* it, since the specification of putenv is that it uses the memory for its arg.
*/
int setenv (const char *name, const char *value, int overwrite) {
char *b;
b = malloc (strlen (name) + strlen (value) + 2 /* = and \000 */);
sprintf (b, "%s=%s", name, value);
return putenv (b);
}
void showMem () {
static char buffer[256];
sprintf (buffer, "pmap %d\n", (int)(getpid ()));
system (buffer);
}
#include "ssmmap.c"
#include "totalRam.sysconf.c"
1.1 mlton/runtime/platform/solaris.h
Index: solaris.h
===================================================================
#include <gmp.h>
#include <signal.h>
#include <strings.h>
#include <sys/filio.h> /* For FIONBIO, FIONREAD. */
#include <sys/mman.h>
#include <sys/resource.h>
#include <sys/sockio.h> /* For SIOCATMARK. */
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/times.h>
#include <sys/types.h>
#include <ucontext.h>
#include "setenv.h"
#include "spawn.h"
#define HAS_MREMAP FALSE
#define HAS_TIME_PROFILING TRUE
#define HAS_SIGALTSTACK TRUE
#define HAS_WEAK 1
#define USE_MMAP TRUE
#define LOG_AUTHPRIV LOG_AUTH
#define LOG_PERROR 0
1.1 mlton/runtime/platform/spawn.h
Index: spawn.h
===================================================================
int spawnve (int mode, const char *path, const char * const *argv, const char * const *envp);
int spawnvp (int mode, const char *path, const char * const *argv);
1.1 mlton/runtime/platform/ssmmap.c
Index: ssmmap.c
===================================================================
void *ssmmap (size_t length, size_t dead_low, size_t dead_high) {
void *base,*low,*result,*high;
base = smmap (length + dead_low + dead_high);
low = base;
if (mprotect (low, dead_low, PROT_NONE))
diee ("mprotect failed");
result = low + dead_low;
high = result + length;
if (mprotect (high, dead_high, PROT_NONE))
diee ("mprotect failed");
return result;
}
1.1 mlton/runtime/platform/totalRam.sysconf.c
Index: totalRam.sysconf.c
===================================================================
W32 totalRam (GC_state s) {
W32 maxMem;
W64 tmp;
maxMem = 0x100000000llu - s->pageSize;
tmp = sysconf (_SC_PHYS_PAGES) * (W64)s->pageSize;
return (tmp >= maxMem) ? maxMem: (W32)tmp;
}
1.1 mlton/runtime/platform/totalRam.sysctl.c
Index: totalRam.sysctl.c
===================================================================
W32 totalRam (GC_state s) {
uint mem;
int len, mib[2];
mib[0] = CTL_HW;
mib[1] = HW_PHYSMEM;
len = sizeof(mem);
if (-1 == sysctl (mib, 2, &mem, &len, NULL, 0))
diee ("sysctl failed");
return mem;
}