[MLton] cvs commit: MLton now runs on Darwin!

Stephen Weeks sweeks@mlton.org
Mon, 27 Sep 2004 15:52:15 -0700


sweeks      04/09/27 15:52:13

  Modified:    .        Makefile
               basis-library/integer int.sml
               basis-library/misc primitive.sml
               basis-library/mlton platform.sig platform.sml
               bin      mlton platform regression upgrade-basis
               doc/user-guide Makefile credits.tex platform.tex
               include  c-chunk.h
               lib/mlton-stubs int-inf.sig mlton.sig mlton.sml platform.sig
                        pointer.sig thread.sig
               mlton/control control.sml
               mlton/elaborate elaborate-core.fun
               mlton/main lookup-constant.fun main.fun
               runtime  Makefile gc.c platform.h
               runtime/Posix/ProcEnv environ.c
               runtime/basis CommandLine.c IEEEReal.c
               runtime/basis/Int Word.c
               runtime/basis/Real class.c gdtoa.c signBit.c
               runtime/platform cygwin.h freebsd.h linux.h mingw.h netbsd.h
                        openbsd.h solaris.h
  Added:       doc/user-guide darwin.tex linux.tex
               runtime/platform darwin.c darwin.h
  Log:
  MAIL MLton now runs on Darwin!
  
  Incorporated Filip Pizlo's patch to make MLton run on Darwin.  All in
  all a quite small patch, showing how easy it is to port MLton to a new
  (unix-ish) platform using the C codegen.
  
  All regressions pass except for real, which has a few differences in
  low-order bits on some tests.
  
  Self compile works without problems.
  
  I reworked the handling of the constants MLton_Platform_{Arch,OS}_host
  so that they are set to string constants in the appropriate
  runtime/platform/*.h file, and the string constants are checked in
  basis-library/misc/primitive.sml.  This makes it possible to add a new
  platform without modifying existing ones.  It did stress compile-time
  string constants, which were otherwise unused.  Right now, I'm not
  doing any escaping of them, so that the string constants can not
  contain spaces or other funny characters.

Revision  Changes    Path
1.125     +13 -6     mlton/Makefile

Index: Makefile
===================================================================
RCS file: /cvsroot/mlton/mlton/Makefile,v
retrieving revision 1.124
retrieving revision 1.125
diff -u -r1.124 -r1.125
--- Makefile	26 Sep 2004 19:13:04 -0000	1.124
+++ Makefile	27 Sep 2004 22:52:08 -0000	1.125
@@ -19,6 +19,7 @@
 PATH = $(BIN):$(shell echo $$PATH)
 CP = /bin/cp -fpR
 GZIP = gzip --force --best
+RANLIB = ranlib
 
 VERSION = $(shell date +%Y%m%d)
 RELEASE = 1
@@ -219,6 +220,7 @@
 	$(MAKE) -C bytecode
 	bytecode/print-opcodes >$(LIB)/opcodes
 	ar r $(LIB)/$(TARGET)/libmlton.a bytecode/interpret.o 
+	for x in $(LIB)/$(TARGET)/*.a; do $(RANLIB) $$x; done
 
 .PHONY: script
 script:
@@ -316,12 +318,17 @@
 		cd $(TMAN) && $(GZIP) mllex.1 mlprof.1 mlton.1		\
 			mlyacc.1;					\
 	fi
-	if [ $(TARGET_OS) != solaris ]; then					\
-	for f in $(TLIB)/$(AOUT) 						\
-		$(TBIN)/$(LEX) $(TBIN)/$(PROF) $(TBIN)/$(YACC); do 		\
-		strip --remove-section=.comment --remove-section=.note $$f; 	\
-	done									\
-	fi
+	case "$(TARGET_OS)" in						\
+	darwin|solaris)							\
+	;;								\
+	*)								\
+		for f in $(TLIB)/$(AOUT) 				\
+			$(TBIN)/$(LEX) $(TBIN)/$(PROF)			\
+			$(TBIN)/$(YACC); do 				\
+			strip --remove-section=.comment			\
+				--remove-section=.note $$f; 		\
+		done							\
+	esac
 
 .PHONY: install-docs
 install-docs:



1.5       +13 -0     mlton/basis-library/integer/int.sml

Index: int.sml
===================================================================
RCS file: /cvsroot/mlton/mlton/basis-library/integer/int.sml,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- int.sml	17 Jun 2004 00:04:25 -0000	1.4
+++ int.sml	27 Sep 2004 22:52:08 -0000	1.5
@@ -100,6 +100,19 @@
 
 val {compare, min, max} = Util.makeCompare (op <)
 
+(* fmt constructs a string to represent the integer by building it into a
+ * statically allocated buffer.  For the most part, this is a textbook
+ * algorithm: loop starting at the end of the buffer; we use rem to
+ * extract the next digit to put into the buffer; and we use quot to
+ * figure out the part of the integer that we haven't yet formatted.
+ * However, this function uses the negative absolute value of the input
+ * number, which allows it to take into account minInt without any
+ * special-casing.  This requires the rem function to behave in a very
+ * specific way, or else things will go terribly wrong.  This may be a
+ * concern when porting to platforms where the division hardware has a
+ * different interpretation than SML about what happens when doing
+ * division of negative numbers.
+ *)
 local
    (* Allocate a buffer large enough to hold any formatted integer in any radix.
     * The most that will be required is for minInt in binary.



1.123     +17 -13    mlton/basis-library/misc/primitive.sml

Index: primitive.sml
===================================================================
RCS file: /cvsroot/mlton/mlton/basis-library/misc/primitive.sml,v
retrieving revision 1.122
retrieving revision 1.123
diff -u -r1.122 -r1.123
--- primitive.sml	22 Sep 2004 23:37:04 -0000	1.122
+++ primitive.sml	27 Sep 2004 22:52:08 -0000	1.123
@@ -760,24 +760,27 @@
 	       struct
 		  structure Arch =
 		     struct
-			datatype t = Sparc | X86
+			datatype t = PowerPC | Sparc | X86
 
 			val host: t =
-			   case _const "MLton_Platform_Arch_host": int; of
-			      0 => Sparc
-			    | 1 => X86
+			   case _const "MLton_Platform_Arch_host": string; of
+			      "powerpc" => PowerPC
+			    | "sparc" => Sparc
+			    | "x86" => X86
 			    | _ => raise Fail "strange MLton_Platform_Arch_host"
 
 			val isBigEndian =
 			   case host of
-			      X86 => false
+			      PowerPC => true
 			    | Sparc => true
+			    | X86 => false
 		     end
 
 		  structure OS =
 		     struct
 			datatype t =
 			   Cygwin
+			 | Darwin
 			 | FreeBSD
 			 | Linux
 			 | MinGW
@@ -786,14 +789,15 @@
 			 | Solaris
 
 			val host: t =
-			   case _const "MLton_Platform_OS_host": int; of
-			      0 => Cygwin
-			    | 1 => FreeBSD
-			    | 2 => Linux
-			    | 3 => MinGW
-			    | 4 => NetBSD
-			    | 5 => OpenBSD
-			    | 6 => Solaris
+			   case _const "MLton_Platform_OS_host": string; of
+			      "cygwin" => Cygwin
+			    | "darwin" => Darwin
+			    | "freebsd" => FreeBSD
+			    | "linux" => Linux
+			    | "mingw" => MinGW
+			    | "netbsd" => NetBSD
+			    | "openbsd" => OpenBSD
+			    | "solaris" => Solaris
 			    | _ => raise Fail "strange MLton_Platform_OS_Host"
 		     end
 	       end



1.8       +3 -1      mlton/basis-library/mlton/platform.sig

Index: platform.sig
===================================================================
RCS file: /cvsroot/mlton/mlton/basis-library/mlton/platform.sig,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- platform.sig	25 Aug 2004 17:51:06 -0000	1.7
+++ platform.sig	27 Sep 2004 22:52:08 -0000	1.8
@@ -2,10 +2,11 @@
    sig
       structure Arch:
 	 sig
-	    datatype t = Sparc | X86
+	    datatype t = PowerPC | Sparc | X86
 
 	    val fromString: string -> t option
 	    val host: t
+	    val isBigEndian: t -> bool
 	    val toString: t -> string
 	 end
 	 
@@ -13,6 +14,7 @@
 	 sig
 	    datatype t =
 	       Cygwin
+	     | Darwin
 	     | FreeBSD
 	     | Linux
 	     | MinGW



1.7       +7 -1      mlton/basis-library/mlton/platform.sml

Index: platform.sml
===================================================================
RCS file: /cvsroot/mlton/mlton/basis-library/mlton/platform.sml,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- platform.sml	25 Aug 2004 17:51:06 -0000	1.6
+++ platform.sml	27 Sep 2004 22:52:08 -0000	1.7
@@ -9,7 +9,7 @@
 	 struct
 	    open Arch
 
-	    val all = [(Sparc, "Sparc"), (X86, "X86")]
+	    val all = [(PowerPC, "PowerPC"), (Sparc, "Sparc"), (X86, "X86")]
 
 	    fun fromString s =
 	       let
@@ -18,6 +18,11 @@
 		  omap (peek (all, fn (_, s') => s = String.toLower s'), #1)
 	       end
 
+	    val isBigEndian =
+	       fn PowerPC => true
+		| Sparc => true
+		| X86 => false
+
 	    fun toString a = #2 (valOf (peek (all, fn (a', _) => a = a')))
 	 end
 
@@ -26,6 +31,7 @@
 	    open OS
 
 	    val all = [(Cygwin, "Cygwin"),
+		       (Darwin, "Darwin"),
 		       (FreeBSD, "FreeBSD"),
 		       (Linux, "Linux"),
 		       (MinGW, "MinGW"),



1.38      +1 -0      mlton/bin/mlton

Index: mlton
===================================================================
RCS file: /cvsroot/mlton/mlton/bin/mlton,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -r1.37 -r1.38
--- mlton	23 Sep 2004 19:34:44 -0000	1.37
+++ mlton	27 Sep 2004 22:52:09 -0000	1.38
@@ -70,6 +70,7 @@
 		-mv8
 		-mcpu=ultrasparc'				\
 	-target-link-opt cygwin '-lgmp'				\
+ 	-target-link-opt darwin '-lgmp'				\
 	-target-link-opt freebsd '-L/usr/local/lib/ -lgmp'	\
 	-target-link-opt linux '-ldl'				\
 	-target-link-opt mingw 					\



1.5       +9 -3      mlton/bin/platform

Index: platform
===================================================================
RCS file: /cvsroot/mlton/mlton/bin/platform,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- platform	25 Aug 2004 17:51:07 -0000	1.4
+++ platform	27 Sep 2004 22:52:09 -0000	1.5
@@ -26,15 +26,18 @@
 uname=`uname`
 
 case "$uname" in
-Linux)
-	HOST_OS='linux'
-;;
 CYGWIN*)
 	HOST_OS='cygwin'
 ;;
+Darwin)
+	HOST_OS='darwin'
+;;
 FreeBSD*)
 	HOST_OS='freebsd'
 ;;
+Linux)
+	HOST_OS='linux'
+;;
 MINGW*)
 	HOST_OS='mingw'
 ;;
@@ -57,6 +60,9 @@
 case "$arch" in
 i?86)
 	HOST_ARCH=x86
+;;
+Power*)
+	HOST_ARCH=powerpc
 ;;
 sun*)
 	HOST_ARCH=sparc



1.99      +4 -4      mlton/bin/regression

Index: regression
===================================================================
RCS file: /cvsroot/mlton/mlton/bin/regression,v
retrieving revision 1.98
retrieving revision 1.99
diff -u -r1.98 -r1.99
--- regression	15 Sep 2004 18:56:52 -0000	1.98
+++ regression	27 Sep 2004 22:52:09 -0000	1.99
@@ -142,10 +142,10 @@
 			# it will also include finalize.2.
 			gcc -o $f -w -O1				\
 				-I "../build/lib/include"		\
-				-L "../build/lib/$crossTarget"		\
-				-L /usr/pkg/lib				\
-				-L /usr/local/lib			\
-				$f.[0-9].[cS]				\
+				-L"../build/lib/$crossTarget"		\
+				-L/usr/pkg/lib				\
+				-L/usr/local/lib			\
+				$f.[0-9].[cS] $f.[0-9][0-9].[cS]	\
 				$libs				
 		;;
 		esac



1.12      +22 -3     mlton/bin/upgrade-basis

Index: upgrade-basis
===================================================================
RCS file: /cvsroot/mlton/mlton/bin/upgrade-basis,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- upgrade-basis	25 Aug 2004 17:51:07 -0000	1.11
+++ upgrade-basis	27 Sep 2004 22:52:09 -0000	1.12
@@ -25,6 +25,11 @@
 
 tmp="$$.sml"
 
+echo "val () = print \"I work\"" >$tmp
+if ! mlton $tmp 1>&2; then
+	die "Error: cannot upgrade basis because the compiler doesn't work" 
+fi
+
 feature () {
 	feature="$1"
 	sml="$2"
@@ -90,6 +95,9 @@
 
 eval `$bin/platform`
 case $HOST_ARCH in
+powerpc)
+	arch='PowerPC'
+;;
 sparc)
 	arch='Sparc'
 ;;
@@ -104,6 +112,9 @@
 cygwin)
 	os='Cygwin'
 ;;
+darwin)
+	os='Darwin'
+;;
 freebsd)
 	os='FreeBSD'
 ;;
@@ -140,9 +151,11 @@
 
             structure Arch =
                struct
-                  datatype t = Sparc | X86
+                  datatype t = PowerPC | Sparc | X86
 
-                  val all = [(Sparc, "Sparc"), (X86, "X86")]
+                  val all = [(PowerPC, "PowerPC"), 
+                             (Sparc, "Sparc"), 
+                             (X86, "X86")]
 
                   fun fromString s =
                      let
@@ -153,15 +166,21 @@
 
                   val host = $arch
 
+                  val isBigEndian =
+                    fn PowerPC => true
+                     | Sparc => true
+                     | X86 => false
+
                   fun toString a = #2 (valOf (peek (all, fn (a', _) => a = a')))
                end
 
             structure OS =
                struct
-                  datatype t = Cygwin | FreeBSD | Linux | MinGW | NetBSD 
+                  datatype t = Cygwin | Darwin | FreeBSD | Linux | MinGW | NetBSD
                              | OpenBSD | Solaris
 
                   val all = [(Cygwin, "Cygwin"),
+                             (Darwin, "Darwin"),
                              (FreeBSD, "FreeBSD"),
                              (Linux, "Linux"),
                              (MinGW, "MinGW"),



1.24      +2 -0      mlton/doc/user-guide/Makefile

Index: Makefile
===================================================================
RCS file: /cvsroot/mlton/mlton/doc/user-guide/Makefile,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- Makefile	7 Sep 2004 02:20:27 -0000	1.23
+++ Makefile	27 Sep 2004 22:52:09 -0000	1.24
@@ -8,12 +8,14 @@
 	credits.tex		\
 	cross-compiling.tex	\
 	cygwin.tex		\
+	darwin.tex		\
 	drawbacks.tex		\
 	extensions.tex		\
 	features.tex		\
 	freebsd.tex		\
 	ffi.tex			\
 	getting-started.tex	\
+	linux.tex		\
 	macros.tex		\
 	main.tex		\
 	man-page.tex		\



1.39      +8 -0      mlton/doc/user-guide/credits.tex

Index: credits.tex
===================================================================
RCS file: /cvsroot/mlton/mlton/doc/user-guide/credits.tex,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- credits.tex	25 Aug 2004 17:51:07 -0000	1.38
+++ credits.tex	27 Sep 2004 22:52:09 -0000	1.39
@@ -81,11 +81,19 @@
 for {\mlton}, and helped us to take over the process.
 
 \item
+Filip Pizlo (\mailto{filip}{cs.purdue.edu}) ported {\mlton} to
+Darwin.
+
+\item
 Sam Rushing (\mailto{rushing}{nightmare.com}) ported {\mlton} to FreeBSD.
 
 \item
 Jeffrey Mark Siskind (\mailto{qobi}{purdue.edu}) provided helpful discussions
 and inspiration with his Stalin Scheme compiler.
+
+\item
+Luke Ziarek (\mailto{lziarek}{cs.purdue.edu}) assisted in porting
+{\mlton} to Darwin.
 
 \end{itemize}
 We have also benefited from other software development tools and borrowed code



1.7       +2 -0      mlton/doc/user-guide/platform.tex

Index: platform.tex
===================================================================
RCS file: /cvsroot/mlton/mlton/doc/user-guide/platform.tex,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- platform.tex	7 Sep 2004 01:38:54 -0000	1.6
+++ platform.tex	27 Sep 2004 22:52:09 -0000	1.7
@@ -3,7 +3,9 @@
 This section discusses issues that arise when running or building
 MLton on various platforms.
 \input{cygwin}
+\input{darwin}
 \input{freebsd}
+\input{linux}
 \input{mingw}
 \input{netbsd}
 \input{openbsd}



1.1                  mlton/doc/user-guide/darwin.tex

Index: darwin.tex
===================================================================
\subsec{Running on Darwin}{darwin}

The are no known problems using {\mlton} on Darwin.



1.1                  mlton/doc/user-guide/linux.tex

Index: linux.tex
===================================================================
\subsec{Running on Linux}{linux}

The are no known problems using {\mlton} on Linux.



1.34      +4 -0      mlton/include/c-chunk.h

Index: c-chunk.h
===================================================================
RCS file: /cvsroot/mlton/mlton/include/c-chunk.h,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- c-chunk.h	26 Aug 2004 05:36:23 -0000	1.33
+++ c-chunk.h	27 Sep 2004 22:52:09 -0000	1.34
@@ -6,6 +6,10 @@
 #include "c-common.h"
 #include "types.h"
 
+#ifndef TRUE
+#define TRUE 1
+#endif
+
 #ifndef FALSE
 #define FALSE 0
 #endif



1.7       +0 -1      mlton/lib/mlton-stubs/int-inf.sig

Index: int-inf.sig
===================================================================
RCS file: /cvsroot/mlton/mlton/lib/mlton-stubs/int-inf.sig,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- int-inf.sig	13 Jan 2004 03:38:11 -0000	1.6
+++ int-inf.sig	27 Sep 2004 22:52:09 -0000	1.7
@@ -12,5 +12,4 @@
 	 Big of word vector
        | Small of int
       val rep: t -> rep
-      val size: t -> int
    end



1.21      +3 -1      mlton/lib/mlton-stubs/mlton.sig

Index: mlton.sig
===================================================================
RCS file: /cvsroot/mlton/mlton/lib/mlton-stubs/mlton.sig,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- mlton.sig	25 Aug 2004 17:51:07 -0000	1.20
+++ mlton.sig	27 Sep 2004 22:52:09 -0000	1.21
@@ -1,4 +1,4 @@
-(* Copyright (C) 1999-2002 Henry Cejtin, Matthew Fluet, Suresh
+(* Copyright (C) 1999-2004 Henry Cejtin, Matthew Fluet, Suresh
  *    Jagannathan, and Stephen Weeks.
  * Copyright (C) 1997-1999 NEC Research Institute.
  *
@@ -18,6 +18,8 @@
       val isMLton: bool
       val safe: bool
 (*      val serialize: 'a -> Word8Vector.vector *)
+      val share: 'a -> unit
+      val shareAll: unit -> unit
       val size: 'a -> int
 
       structure Array: MLTON_ARRAY



1.38      +14 -2     mlton/lib/mlton-stubs/mlton.sml

Index: mlton.sml
===================================================================
RCS file: /cvsroot/mlton/mlton/lib/mlton-stubs/mlton.sml,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -r1.37 -r1.38
--- mlton.sml	31 Aug 2004 03:27:39 -0000	1.37
+++ mlton.sml	27 Sep 2004 22:52:09 -0000	1.38
@@ -47,6 +47,8 @@
       val isMLton = Array.maxLen = 0x7FFFFFFF
       val safe = true
       val serialize = fn _ => raise Fail "serialize"
+      val share = fn _ => raise Fail "share"
+      val shareAll = fn _ => raise Fail "shareAll"
       val size = fn _ => ~1: int
 
       structure Array =
@@ -158,14 +160,21 @@
 	 
 	    structure Arch =
 	       struct
-		  datatype t = Sparc | X86
+		  datatype t = PowerPC | Sparc | X86
 
 		  val host: t = X86
 
-		  val all = [(Sparc, "sparc"), (X86, "x86")]
+		  val all = [(PowerPC, "powerpc"),
+			     (Sparc, "sparc"),
+			     (X86, "x86")]
 
 		  fun fromString s = omap (peek (all, fn (_, s') => s = s'), #1)
 
+		  val isBigEndian =
+		     fn PowerPC => true
+		      | Sparc => true
+		      | X86 => false
+			   
 		  fun toString a = #2 (valOf (peek (all, fn (a', _) => a = a')))
 	       end
 
@@ -173,6 +182,7 @@
 	       struct
 		  datatype t =
 		     Cygwin
+		   | Darwin
 		   | FreeBSD
 		   | Linux
 		   | MinGW
@@ -183,6 +193,7 @@
 		  val host: t = Linux
 
 		  val all = [(Cygwin, "cygwin"),
+			     (Darwin, "darwin"),
 			     (FreeBSD, "freebsd"),
 			     (Linux, "linux"),
 			     (MinGW, "mingw"),
@@ -201,6 +212,7 @@
 	    type t = unit
 	       
 	    val add = fn _ => raise Fail "Pointer.add"
+	    val compare = fn _ => raise Fail "Pointer.compare"
 	    val diff = fn _ => raise Fail "Pointer.diff"
 	    val getInt8 = fn _ => raise Fail "Pointer.getInt8"
 	    val getInt16 = fn _ => raise Fail "Pointer.getInt16"



1.8       +3 -1      mlton/lib/mlton-stubs/platform.sig

Index: platform.sig
===================================================================
RCS file: /cvsroot/mlton/mlton/lib/mlton-stubs/platform.sig,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- platform.sig	25 Aug 2004 17:51:07 -0000	1.7
+++ platform.sig	27 Sep 2004 22:52:09 -0000	1.8
@@ -2,10 +2,11 @@
    sig
       structure Arch:
 	 sig
-	    datatype t = Sparc | X86
+	    datatype t = PowerPC | Sparc | X86
 
 	    val fromString: string -> t option
 	    val host: t
+	    val isBigEndian: t -> bool
 	    val toString: t -> string
 	 end
 	 
@@ -13,6 +14,7 @@
 	 sig
 	    datatype t =
 	       Cygwin
+	     | Darwin
 	     | FreeBSD
 	     | Linux
 	     | MinGW



1.3       +1 -0      mlton/lib/mlton-stubs/pointer.sig

Index: pointer.sig
===================================================================
RCS file: /cvsroot/mlton/mlton/lib/mlton-stubs/pointer.sig,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- pointer.sig	6 Jan 2004 05:12:28 -0000	1.2
+++ pointer.sig	27 Sep 2004 22:52:09 -0000	1.3
@@ -3,6 +3,7 @@
       eqtype t
 
       val add: t * word -> t
+      val compare: t * t -> order
       val diff: t * t -> word
       val getInt8: t * int -> Int8.int
       val getInt16: t * int -> Int16.int



1.9       +1 -1      mlton/lib/mlton-stubs/thread.sig

Index: thread.sig
===================================================================
RCS file: /cvsroot/mlton/mlton/lib/mlton-stubs/thread.sig,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- thread.sig	25 Aug 2004 17:51:07 -0000	1.8
+++ thread.sig	27 Sep 2004 22:52:09 -0000	1.9
@@ -28,7 +28,7 @@
       (* 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.
+       * switch-ing to another thread or exiting the process.
        *)
       val new: ('a -> unit) -> 'a t
       (* prepend(t, f)



1.147     +1 -4      mlton/mlton/control/control.sml

Index: control.sml
===================================================================
RCS file: /cvsroot/mlton/mlton/mlton/control/control.sml,v
retrieving revision 1.146
retrieving revision 1.147
diff -u -r1.146 -r1.147
--- control.sml	26 Sep 2004 18:50:16 -0000	1.146
+++ control.sml	27 Sep 2004 22:52:10 -0000	1.147
@@ -662,10 +662,7 @@
 			  default = X86,
 			  toString = MLton.Platform.Arch.toString}
 
-fun targetIsBigEndian () =
-   case !targetArch of
-      X86 => false
-    | Sparc => true
+fun targetIsBigEndian () = MLton.Platform.Arch.isBigEndian (!targetArch)
 
 datatype os = datatype MLton.Platform.OS.t
 



1.125     +2 -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.124
retrieving revision 1.125
diff -u -r1.124 -r1.125
--- elaborate-core.fun	23 Sep 2004 03:13:10 -0000	1.124
+++ elaborate-core.fun	27 Sep 2004 22:52:10 -0000	1.125
@@ -2275,7 +2275,8 @@
 						  (Vector.sub (ts, 0))) of
 					       NONE => false
 					     | SOME (c, _) => 
-						  Tycon.equals (c, Tycon.char))
+						  Tycon.equals
+						  (c, Tycon.word WordSize.byte))
 						then ConstType.String
 					     else
 						bug ()



1.9       +3 -3      mlton/mlton/main/lookup-constant.fun

Index: lookup-constant.fun
===================================================================
RCS file: /cvsroot/mlton/mlton/mlton/main/lookup-constant.fun,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- lookup-constant.fun	15 Sep 2004 18:16:29 -0000	1.8
+++ lookup-constant.fun	27 Sep 2004 22:52:11 -0000	1.9
@@ -42,7 +42,7 @@
 		     in
 			implode [dig 100, dig 10, dig 1]
 		     end)
-   
+
 fun unescape s =
    let
       fun sub i = Char.toInt (String.sub (s, i)) - Char.toInt #"0"
@@ -104,7 +104,7 @@
 	       case ty of
 		  Bool => ("%s", concat [value, "? \"true\" : \"false\""])
 		| Real => ("%.20f", value)
-		| String => ("%s", concat ["\"", escape value, "\""])
+		| String => ("%s", value)
 		| Word => ("%u", value)
 	 in
 	    concat ["fprintf (stdout, \"", name, " = ", format, "\\n\", ",
@@ -184,7 +184,7 @@
 		  (case RealX.make (value, RealSize.default) of
 		      NONE => error "real"
 		    | SOME r => Const.Real r)
-	     | String => Const.string (unescape value)
+	     | String => Const.string value
 	     | Word =>
 		  (case IntInf.fromString value of
 		      NONE => error "int"



1.67      +19 -7     mlton/mlton/main/main.fun

Index: main.fun
===================================================================
RCS file: /cvsroot/mlton/mlton/mlton/main/main.fun,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -r1.66 -r1.67
--- main.fun	26 Sep 2004 18:50:16 -0000	1.66
+++ main.fun	27 Sep 2004 22:52:11 -0000	1.67
@@ -95,7 +95,8 @@
 	    targetArch := arch
 	    ; targetOS := os
 	    ; (case arch of
-		  Sparc => (align := Align8; codegen := CCodegen)
+		  PowerPC => codegen := CCodegen
+		| Sparc => (align := Align8; codegen := CCodegen)
 		| _ => ())
 	 end
 
@@ -108,6 +109,16 @@
    (warnDeprecated (flag, concat ["-const '", name, " <value>'"])
     ; Compile.setCommandLineConstant {name = name, value = value})
 
+fun hasNative () =
+   let
+      datatype z = datatype Control.arch
+   in
+      case !Control.targetArch of
+	 PowerPC => false
+       | Sparc => false
+       | X86 => true
+   end
+
 fun makeOptions {usage} = 
    let
       val usage = fn s => (usage s; raise Fail "unreachable")
@@ -120,7 +131,8 @@
        [
        (Normal, "align",
 	case !targetArch of
-	   Sparc => " {8|4}"
+	   PowerPC => " {4|8}"
+	 | Sparc => " {8|4}"
 	 | X86 => " {4|8}",
 	"object alignment",
 	(SpaceString (fn s =>
@@ -165,7 +177,7 @@
        (Expert, "coalesce", " <n>", "coalesce chunk size for C codegen",
 	Int (fn n => coalesce := SOME n)),
        (Normal, "codegen",
-	if !targetArch = Sparc then " {c}" else " {native|bytecode|c}",
+	if hasNative () then " {native|c}" else " {c}",
 	"which code generator to use",
 	SpaceString (fn s =>
 		     case s of
@@ -324,8 +336,7 @@
 	boolRef markCards),
        (Expert, "max-function-size", " <n>", "max function size (blocks)",
 	intRef maxFunctionSize),
-       (Expert, "native",
-	if !targetArch = Sparc then " {false}" else " {true|false}",
+       (Expert, "native", if hasNative () then " {true|false}" else " {false}",
 	"use native code generator",
 	Bool (fn b =>
 	      (warnDeprecated ("native", "-codegen")
@@ -605,8 +616,9 @@
 		      linkWithGmp,
 		      addTargetOpts linkOpts]
       val _ =
-	 if !Control.codegen = Native andalso targetArch = Sparc
-	    then usage "can't use native codegen on Sparc"
+	 if !Control.codegen = Native andalso not (hasNative ())
+	    then usage (concat ["can't use native codegen on ",
+				MLton.Platform.Arch.toString targetArch])
 	 else ()
       val _ =
 	 chunk :=



1.90      +12 -0     mlton/runtime/Makefile

Index: Makefile
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Makefile,v
retrieving revision 1.89
retrieving revision 1.90
diff -u -r1.89 -r1.90
--- Makefile	8 Sep 2004 00:40:23 -0000	1.89
+++ Makefile	27 Sep 2004 22:52:11 -0000	1.90
@@ -24,10 +24,19 @@
 FLAGS += -Wa,-xarch=v8plusa -fcall-used-g5 -fcall-used-g7 -funroll-all-loops -m32 -mv8 -mcpu=ultrasparc
 endif
 
+# The following defines are a hack to work around the fact the
+# strto{d,f} are defined in libc on Darwin, and hence cannot be also
+# defined by libgdtoa.
+ifeq ($(TARGET_OS), darwin)
+FLAGS += -Dstrtod=mlton_strtod -Dstrtof=mlton_strtof
+endif
+
 ifeq ($(TARGET), self)
 AR = ar rc
+RANLIB = ranlib
 else
 AR = $(TARGET)-ar rc
+RANLIB = $(TARGET)-ranlib
 FLAGS += -b $(TARGET)
 endif
 
@@ -74,6 +83,7 @@
 libgdtoa.a: gdtoa/arith.h
 	cd gdtoa && $(CC) $(CFLAGS) -w -O1 -c -DINFNAN_CHECK *.c
 	$(AR) libgdtoa.a gdtoa/*.o
+	$(RANLIB) libgdtoa.a
 
 gdtoa/arithchk.c:
 	zcat gdtoa.tgz | tar xf -	
@@ -87,9 +97,11 @@
 
 libmlton.a: $(OBJS) 
 	$(AR) libmlton.a $(OBJS)
+	$(RANLIB) libmlton.a	
 
 libmlton-gdb.a: $(DEBUG_OBJS)
 	$(AR) libmlton-gdb.a $(DEBUG_OBJS)
+	$(RANLIB) libmlton-gdb.a
 
 runtime.c: $(CFILES)
 	cat $(CFILES) >runtime.c



1.207     +15 -5     mlton/runtime/gc.c

Index: gc.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/gc.c,v
retrieving revision 1.206
retrieving revision 1.207
diff -u -r1.206 -r1.207
--- gc.c	14 Sep 2004 00:58:40 -0000	1.206
+++ gc.c	27 Sep 2004 22:52:11 -0000	1.207
@@ -3781,7 +3781,11 @@
 /*
  * Called on each SIGPROF interrupt.
  */
-#if (defined (__linux__) || defined (__FreeBSD__) || defined (__OpenBSD__) || defined (__sun__))
+#if (defined (__Darwin__) ||\
+	defined (__FreeBSD__) ||\
+	defined (__linux__) ||\
+	defined (__OpenBSD__) ||\
+	defined (__sun__))
 static void catcher (int sig, siginfo_t *sip, ucontext_t *ucp) {
 #elif (defined (__NetBSD__))
 static void catcher (int sig, int code, struct sigcontext *ucp) {
@@ -3794,13 +3798,15 @@
 	uint sourceSeqIndex;
 
 	s = catcherState;
-#if (defined (__linux__))
+#if (defined (__Darwin__))
+ 	pc = (pointer) ucp->uc_mcontext->ss.srr0;
+#elif (defined (__FreeBSD__))
+	pc = (pointer) ucp->uc_mcontext.mc_eip;
+#elif (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;
 #elif (defined (__NetBSD__) || defined (__OpenBSD__))
 	pc = (pointer) ucp->sc_eip;
 #elif (defined (__sun__))
@@ -3901,7 +3907,11 @@
 	catcherState = s;
 	sa.sa_handler = (void (*)(int))catcher;
 	sigemptyset (&sa.sa_mask);
-#if (defined (__linux__) || defined (__FreeBSD__) || defined (__OpenBSD__) || defined (__sun__))
+#if (defined (__Darwin__) ||\
+	defined (__FreeBSD__) ||\
+	defined (__linux__) ||\
+	defined (__OpenBSD__) ||\
+	defined (__sun__))
 	sa.sa_flags = SA_ONSTACK | SA_RESTART | SA_SIGINFO;
 #elif (defined (__NetBSD__))
 	sa.sa_flags = SA_ONSTACK | SA_RESTART;



1.6       +17 -21    mlton/runtime/platform.h

Index: platform.h
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/platform.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- platform.h	7 Sep 2004 00:46:20 -0000	1.5
+++ platform.h	27 Sep 2004 22:52:12 -0000	1.6
@@ -28,8 +28,14 @@
 
 #include "assert.h"
 
+#if (defined (__APPLE_CC__))
+#define __Darwin__
+#endif
+
 #if (defined (__CYGWIN__))
 #include "platform/cygwin.h"
+#elif (defined (__Darwin__))
+#include "platform/darwin.h"
 #elif (defined (__FreeBSD__))
 #include "platform/freebsd.h"
 #elif (defined (__linux__))
@@ -42,6 +48,8 @@
 #include "platform/openbsd.h"
 #elif (defined (__sun__))
 #include "platform/solaris.h"
+#else
+#error unknown platform
 #endif
 
 #ifndef EXECVP
@@ -52,6 +60,10 @@
 #define EXECVE execve
 #endif
 
+#ifndef MLton_Platform_OS_host
+#error MLton_Platform_OS_host not defined
+#endif
+
 #ifndef HAS_MREMAP
 #error HAS_MREMAP not defined
 #endif
@@ -337,30 +349,14 @@
 /*           MLton.Platform           */
 /* ---------------------------------- */
 
-#if (defined (__sparc__))
-#define MLton_Platform_Arch_host 0
+#if (defined (__ppc__))
+#define MLton_Platform_Arch_host "powerpc"
+#elif (defined (__sparc__))
+#define MLton_Platform_Arch_host "sparc"
 #elif (defined (__i386__))
-#define MLton_Platform_Arch_host 1
+#define MLton_Platform_Arch_host "x86"
 #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 (__MINGW32__))
-#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
 
 /* ---------------------------------- */



1.3       +2 -1      mlton/runtime/Posix/ProcEnv/environ.c

Index: environ.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/Posix/ProcEnv/environ.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- environ.c	25 Aug 2004 17:51:13 -0000	1.2
+++ environ.c	27 Sep 2004 22:52:12 -0000	1.3
@@ -1,4 +1,5 @@
 #include "platform.h"
 
-CstringArray Posix_ProcEnv_environ;
+/* Manual initialization is a work-around for a Darwin linker issue. */
+CstringArray Posix_ProcEnv_environ = 0;
 



1.3       +4 -3      mlton/runtime/basis/CommandLine.c

Index: CommandLine.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/basis/CommandLine.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- CommandLine.c	25 Aug 2004 17:51:16 -0000	1.2
+++ CommandLine.c	27 Sep 2004 22:52:12 -0000	1.3
@@ -1,5 +1,6 @@
 #include "platform.h"
 
-Int CommandLine_argc;
-CstringArray CommandLine_argv;
-Cstring CommandLine_commandName;
+/* Manual initialization is a work-around for a Darwin linker issue. */
+Int CommandLine_argc = 0;
+CstringArray CommandLine_argv = 0;
+Cstring CommandLine_commandName = 0;



1.7       +73 -0     mlton/runtime/basis/IEEEReal.c

Index: IEEEReal.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/basis/IEEEReal.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- IEEEReal.c	4 Sep 2004 03:40:09 -0000	1.6
+++ IEEEReal.c	27 Sep 2004 22:52:12 -0000	1.7
@@ -29,6 +29,79 @@
 	return (controlWord & ROUNDING_CONTROL_MASK) >> ROUNDING_CONTROL_SHIFT;
 }
 
+#elif (defined (__ppc__))
+
+#include <ppc_intrinsics.h>
+
+/* PPC rounding control works as follows:
+ *
+ * The FPSCR (floating point status and control register) contains
+ * the rounding mode in bits 30 and 31 (in PPC notation, these are the
+ * least significant bits).  These bits have the following meaning:
+ *
+ * 00   Round to nearest
+ * 01   Round toward zero
+ * 10   Round toward +Infinity
+ * 11   Round toward -Infinity
+ *
+ * The messed up thing about the way that the FPSCR is accessed is that
+ * you can only load from it into a floating point register - so to get
+ * at the actual bits, you have to "bounce" the floating point value off
+ * memory to place it into an integer register.  A similar problem
+ * occurs when you want to place a value into the FPSCR - you have to
+ * first get the value into a floating point register first.
+ *
+ * Source: ARCHPUB1.PDF (you can get it at IBM's developerWorks) */
+
+void IEEEReal_setRoundingMode (Int mode) {
+	int ppc_mode;
+	
+	union {
+		double d;
+		long long q;
+	} u;
+	
+	switch (mode) {
+		/* TO_NEAREST */
+		case 0: ppc_mode = 0; break;
+		/* TO_NEGINF */
+		case 1: ppc_mode = 3; break;
+		/* TO_POSINF */
+		case 2: ppc_mode = 2; break;
+		/* TO_ZERO */
+		case 3: ppc_mode = 1; break;
+		default:
+			die ("IEEEReal_setRoundingMode error: invalid mode %d\n",
+				(int)mode);
+	}
+	u.d=__mffs();
+	u.q=(u.q&~3)|ppc_mode;
+	__mtfsf(255,u.d);	/* indicate that I wish to set all fields; this is the
+					       recommended thing to do according to the IBM manual */
+}
+
+Int IEEEReal_getRoundingMode () {
+	union {
+		double d;
+		long long q;
+	} u;
+	
+	u.d=__mffs();
+	
+	switch (u.q&3) {
+		/* TO_NEAREST */
+		case 0: return 0;
+		/* TO_NEGINF */
+		case 3: return 1;
+		/* TO_POSINF */
+		case 2: return 2;
+		/* TO_ZERO */
+		case 1: return 3;
+		default:
+			die ("IEEEReal_getRoundingMode error: apparently, the compiler didn't understand clearly when I said &~3.\n");
+	}
+}
+
 #elif (defined (__sparc__))
 
 #include <ieeefp.h>



1.4       +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.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Word.c	27 Aug 2004 00:50:43 -0000	1.3
+++ Word.c	27 Sep 2004 22:52:12 -0000	1.4
@@ -28,7 +28,7 @@
 #define DEBUG FALSE
 #endif
 
-#if ! (defined (__i386__) || defined (__sparc__))
+#if ! (defined (__i386__) || defined (__ppc__) || defined (__sparc__))
 #error check that C {/,%} correctly implement {quot,rem} from the basis library
 #endif
 



1.11      +16 -0     mlton/runtime/basis/Real/class.c

Index: class.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/basis/Real/class.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- class.c	28 Aug 2004 19:00:22 -0000	1.10
+++ class.c	27 Sep 2004 22:52:12 -0000	1.11
@@ -80,6 +80,22 @@
 	return res;
 }
 
+#elif (defined __ppc__ && defined __Darwin__)
+
+Int Real64_class (Real64 d) {
+	int c = fpclassify (d);
+	switch (c) {
+		/* FIXME: not distinguishing between nanSignalling and nanQuiet */
+		case FP_NAN:		return Real_Class_nanQuiet;
+		case FP_INFINITE:	return Real_Class_inf;
+		case FP_ZERO:		return Real_Class_zero;
+		case FP_NORMAL:		return Real_Class_normal;
+		case FP_SUBNORMAL:	return Real_Class_subnormal;
+		default: die("Real_class error: invalid class %d\n", c);
+	}
+}
+
+
 #elif (defined __sparc__)
 
 Int Real64_class (Real64 d) {



1.6       +1 -1      mlton/runtime/basis/Real/gdtoa.c

Index: gdtoa.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/basis/Real/gdtoa.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- gdtoa.c	27 Aug 2004 00:50:44 -0000	1.5
+++ gdtoa.c	27 Sep 2004 22:52:12 -0000	1.6
@@ -9,7 +9,7 @@
 #define _0 1
 #define _1 0
 
-#elif (defined (__sparc__))
+#elif (defined (__ppc__) || defined (__sparc__))
 #define _0 0
 #define _1 1
 



1.6       +1 -1      mlton/runtime/basis/Real/signBit.c

Index: signBit.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/basis/Real/signBit.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- signBit.c	25 Aug 2004 17:51:19 -0000	1.5
+++ signBit.c	27 Sep 2004 22:52:12 -0000	1.6
@@ -7,7 +7,7 @@
 	R64_byte = 7,
 };
 
-#elif (defined __sparc__)
+#elif (defined __ppc__ || defined __sparc__)
 
 enum {
 	R32_byte = 0,



1.5       +2 -0      mlton/runtime/platform/cygwin.h

Index: cygwin.h
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/platform/cygwin.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- cygwin.h	5 Sep 2004 23:43:10 -0000	1.4
+++ cygwin.h	27 Sep 2004 22:52:13 -0000	1.5
@@ -21,6 +21,8 @@
 
 #include "gmp.h"
 
+#define MLton_Platform_OS_host "cygwin"
+
 #define HAS_MREMAP FALSE
 #define HAS_PTRACE FALSE
 #define HAS_SIGALTSTACK FALSE



1.5       +2 -0      mlton/runtime/platform/freebsd.h

Index: freebsd.h
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/platform/freebsd.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- freebsd.h	5 Sep 2004 23:43:10 -0000	1.4
+++ freebsd.h	27 Sep 2004 22:52:13 -0000	1.5
@@ -34,3 +34,5 @@
 #define HAS_TIME_PROFILING TRUE
 #define HAS_WEAK 1
 #define USE_MMAP TRUE
+
+#define MLton_Platform_OS_host "freebsd"



1.5       +2 -0      mlton/runtime/platform/linux.h

Index: linux.h
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/platform/linux.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- linux.h	5 Sep 2004 23:43:10 -0000	1.4
+++ linux.h	27 Sep 2004 22:52:13 -0000	1.5
@@ -29,6 +29,8 @@
 #define HAS_WEAK 1
 #define USE_MMAP TRUE
 
+#define MLton_Platform_OS_host "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



1.7       +2 -0      mlton/runtime/platform/mingw.h

Index: mingw.h
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/platform/mingw.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- mingw.h	5 Sep 2004 23:43:10 -0000	1.6
+++ mingw.h	27 Sep 2004 22:52:13 -0000	1.7
@@ -21,6 +21,8 @@
 #define HAS_WEAK FALSE
 #define USE_VIRTUAL_ALLOC TRUE
 
+#define MLton_Platform_OS_host "mingw"
+
 typedef unsigned short gid_t;
 typedef unsigned short uid_t;
 



1.5       +2 -0      mlton/runtime/platform/netbsd.h

Index: netbsd.h
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/platform/netbsd.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- netbsd.h	5 Sep 2004 23:43:10 -0000	1.4
+++ netbsd.h	27 Sep 2004 22:52:13 -0000	1.5
@@ -32,3 +32,5 @@
 #define HAS_TIME_PROFILING TRUE
 #define HAS_WEAK 1
 #define USE_MMAP TRUE
+
+#define MLton_Platform_OS_host "netbsd"



1.5       +2 -0      mlton/runtime/platform/openbsd.h

Index: openbsd.h
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/platform/openbsd.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- openbsd.h	5 Sep 2004 23:43:10 -0000	1.4
+++ openbsd.h	27 Sep 2004 22:52:13 -0000	1.5
@@ -32,3 +32,5 @@
 #define HAS_TIME_PROFILING TRUE
 #define HAS_WEAK 1
 #define USE_MMAP TRUE
+
+#define MLton_Platform_OS_host "openbsd"



1.6       +2 -0      mlton/runtime/platform/solaris.h

Index: solaris.h
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/platform/solaris.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- solaris.h	23 Sep 2004 19:34:09 -0000	1.5
+++ solaris.h	27 Sep 2004 22:52:13 -0000	1.6
@@ -32,5 +32,7 @@
 #define HAS_WEAK 1
 #define USE_MMAP TRUE
 
+#define MLton_Platform_OS_host "solaris"
+
 #define LOG_AUTHPRIV LOG_AUTH
 #define LOG_PERROR 0



1.1                  mlton/runtime/platform/darwin.c

Index: darwin.c
===================================================================
#include "platform.h"

#include "mkdir2.c"

void showMem () {
	/* FIXME: this won't actually work. */
	
	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;
	size_t len;

	len = sizeof (int);
	if (-1 == sysctlbyname ("hw.physmem", &mem, &len, NULL, 0))
		diee ("sysctl failed");
	return mem;
}



1.1                  mlton/runtime/platform/darwin.h

Index: darwin.h
===================================================================
#include <grp.h>
#include <limits.h>
#include <netdb.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <netinet/udp.h>
#include <pwd.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/poll.h>
#include <sys/ptrace.h>
#include <sys/resource.h>
#include <sys/socket.h>
#include <sys/sysctl.h>
#include <sys/times.h>
#include <sys/un.h>
#include <sys/utsname.h>
#include <sys/wait.h>
#include <syslog.h>
#include <termios.h>
#include <ucontext.h>

/* As far as I can tell, gmp does not come with Mac OS X, so the user will
 * install it himself in /usr/local.
 */
#include "/usr/local/include/gmp.h"

#define HAS_SPAWN FALSE
#define HAS_MREMAP FALSE
#define HAS_SIGALTSTACK TRUE
#define HAS_TIME_PROFILING FALSE
#define HAS_WEAK 0
#define USE_MMAP TRUE

#define MLton_Platform_OS_host "darwin"