[MLton-commit] r4416

Matthew Fluet MLton@mlton.org
Tue, 25 Apr 2006 11:35:25 -0700


Refactored PackReal
----------------------------------------------------------------------

U   mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/build/sources.mlb
U   mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/int-inf.sig
U   mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/integer.sig
U   mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/basis-ffi.sml
A   mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/check-pack-real.sml
A   mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/check-real.sml
A   mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/prim-pack-real.sml
U   mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/prim-real.sml
U   mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/primitive.mlb
U   mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/primitive.sml
U   mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/real/pack-real.sml
U   mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/real/real.sig
U   mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/real/real.sml
U   mlton/branches/on-20050822-x86_64-branch/runtime/basis/Int/PackWord.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/Math.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/PackReal.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/class.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/frexp.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/gdtoa.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/modf.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/nextAfter.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/signBit.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/strto.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/gen/basis-ffi.def
U   mlton/branches/on-20050822-x86_64-branch/runtime/platform.h

----------------------------------------------------------------------

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/build/sources.mlb
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/build/sources.mlb	2006-04-25 17:35:46 UTC (rev 4415)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/build/sources.mlb	2006-04-25 18:35:12 UTC (rev 4416)
@@ -172,7 +172,7 @@
    ../real/real.sig
    ../real/real.sml
    ../real/pack-real.sig
-   (* ../real/pack-real.sml *)
+   ../real/pack-real.sml
    local 
       ../config/bind/real-top.sml 
    in ann "forceUsed" in

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/int-inf.sig
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/int-inf.sig	2006-04-25 17:35:46 UTC (rev 4415)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/int-inf.sig	2006-04-25 18:35:12 UTC (rev 4416)
@@ -33,4 +33,9 @@
       val *? : int * int -> int
       val -? : int * int -> int
       val ~? : int -> int
+
+      val ltu: int * int -> bool
+      val leu: int * int -> bool
+      val gtu: int * int -> bool
+      val geu: int * int -> bool
    end

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/integer.sig
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/integer.sig	2006-04-25 17:35:46 UTC (rev 4415)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/integer.sig	2006-04-25 18:35:12 UTC (rev 4416)
@@ -63,6 +63,11 @@
       val ~>> : int * Primitive.Word32.word -> int
       val >> : int * Primitive.Word32.word -> int
       val xorb: int * int -> int
+
+      val ltu: int * int -> bool
+      val leu: int * int -> bool
+      val gtu: int * int -> bool
+      val geu: int * int -> bool
    end
 
 signature INTEGER =
@@ -103,4 +108,9 @@
       val ~>> : int * Word.word -> int
       val >> : int * Word.word -> int
       val xorb: int * int -> int
+
+      val ltu: int * int -> bool
+      val leu: int * int -> bool
+      val gtu: int * int -> bool
+      val geu: int * int -> bool
    end

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/basis-ffi.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/basis-ffi.sml	2006-04-25 17:35:46 UTC (rev 4415)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/basis-ffi.sml	2006-04-25 18:35:12 UTC (rev 4416)
@@ -204,6 +204,24 @@
 val POLLPRI = _const "OS_IO_POLLPRI" : C_Short.t;
 end
 end
+structure PackReal32 = 
+struct
+val subArr = _import "PackReal32_subArr" : (Word8.t) array * C_Ptrdiff.t -> Real32.t;
+val subArrRev = _import "PackReal32_subArrRev" : (Word8.t) array * C_Ptrdiff.t -> Real32.t;
+val subVec = _import "PackReal32_subVec" : (Word8.t) vector * C_Ptrdiff.t -> Real32.t;
+val subVecRev = _import "PackReal32_subVecRev" : (Word8.t) vector * C_Ptrdiff.t -> Real32.t;
+val update = _import "PackReal32_update" : (Word8.t) array * C_Ptrdiff.t * Real32.t -> unit;
+val updateRev = _import "PackReal32_updateRev" : (Word8.t) array * C_Ptrdiff.t * Real32.t -> unit;
+end
+structure PackReal64 = 
+struct
+val subArr = _import "PackReal64_subArr" : (Word8.t) array * C_Ptrdiff.t -> Real64.t;
+val subArrRev = _import "PackReal64_subArrRev" : (Word8.t) array * C_Ptrdiff.t -> Real64.t;
+val subVec = _import "PackReal64_subVec" : (Word8.t) vector * C_Ptrdiff.t -> Real64.t;
+val subVecRev = _import "PackReal64_subVecRev" : (Word8.t) vector * C_Ptrdiff.t -> Real64.t;
+val update = _import "PackReal64_update" : (Word8.t) array * C_Ptrdiff.t * Real64.t -> unit;
+val updateRev = _import "PackReal64_updateRev" : (Word8.t) array * C_Ptrdiff.t * Real64.t -> unit;
+end
 structure Posix = 
 struct
 structure Error = 
@@ -894,6 +912,78 @@
 end
 end
 end
+structure Real32 = 
+struct
+val abs = _import "Real32_abs" : Real32.t -> Real32.t;
+val class = _import "Real32_class" : Real32.t -> C_Int.t;
+val frexp = _import "Real32_frexp" : Real32.t * (C_Int.t) ref -> Real32.t;
+val gdtoa = _import "Real32_gdtoa" : Real32.t * C_Int.t * C_Int.t * (C_Int.t) ref -> C_String.t;
+val ldexp = _import "Real32_ldexp" : Real32.t * C_Int.t -> Real32.t;
+structure Math = 
+struct
+val acos = _import "Real32_Math_acos" : Real32.t -> Real32.t;
+val asin = _import "Real32_Math_asin" : Real32.t -> Real32.t;
+val atan = _import "Real32_Math_atan" : Real32.t -> Real32.t;
+val atan2 = _import "Real32_Math_atan2" : Real32.t * Real32.t -> Real32.t;
+val cos = _import "Real32_Math_cos" : Real32.t -> Real32.t;
+val cosh = _import "Real32_Math_cosh" : Real32.t -> Real32.t;
+val (eGet, eSet) = _symbol "Real32_Math_e": (unit -> (Real32.t)) * ((Real32.t) -> unit);
+val exp = _import "Real32_Math_exp" : Real32.t -> Real32.t;
+val ln = _import "Real32_Math_ln" : Real32.t -> Real32.t;
+val log10 = _import "Real32_Math_log10" : Real32.t -> Real32.t;
+val (piGet, piSet) = _symbol "Real32_Math_pi": (unit -> (Real32.t)) * ((Real32.t) -> unit);
+val pow = _import "Real32_Math_pow" : Real32.t * Real32.t -> Real32.t;
+val sin = _import "Real32_Math_sin" : Real32.t -> Real32.t;
+val sinh = _import "Real32_Math_sinh" : Real32.t -> Real32.t;
+val sqrt = _import "Real32_Math_sqrt" : Real32.t -> Real32.t;
+val tan = _import "Real32_Math_tan" : Real32.t -> Real32.t;
+val tanh = _import "Real32_Math_tanh" : Real32.t -> Real32.t;
+end
+val (maxFiniteGet, maxFiniteSet) = _symbol "Real32_maxFinite": (unit -> (Real32.t)) * ((Real32.t) -> unit);
+val (minNormalPosGet, minNormalPosSet) = _symbol "Real32_minNormalPos": (unit -> (Real32.t)) * ((Real32.t) -> unit);
+val (minPosGet, minPosSet) = _symbol "Real32_minPos": (unit -> (Real32.t)) * ((Real32.t) -> unit);
+val modf = _import "Real32_modf" : Real32.t * (Real32.t) ref -> Real32.t;
+val nextAfter = _import "Real32_nextAfter" : Real32.t * Real32.t -> Real32.t;
+val round = _import "Real32_round" : Real32.t -> Real32.t;
+val signBit = _import "Real32_signBit" : Real32.t -> C_Int.t;
+val strto = _import "Real32_strto" : NullString8.t -> Real32.t;
+end
+structure Real64 = 
+struct
+val abs = _import "Real64_abs" : Real64.t -> Real64.t;
+val class = _import "Real64_class" : Real64.t -> C_Int.t;
+val frexp = _import "Real64_frexp" : Real64.t * (C_Int.t) ref -> Real64.t;
+val gdtoa = _import "Real64_gdtoa" : Real64.t * C_Int.t * C_Int.t * (C_Int.t) ref -> C_String.t;
+val ldexp = _import "Real64_ldexp" : Real64.t * C_Int.t -> Real64.t;
+structure Math = 
+struct
+val acos = _import "Real64_Math_acos" : Real64.t -> Real64.t;
+val asin = _import "Real64_Math_asin" : Real64.t -> Real64.t;
+val atan = _import "Real64_Math_atan" : Real64.t -> Real64.t;
+val atan2 = _import "Real64_Math_atan2" : Real64.t * Real64.t -> Real64.t;
+val cos = _import "Real64_Math_cos" : Real64.t -> Real64.t;
+val cosh = _import "Real64_Math_cosh" : Real64.t -> Real64.t;
+val (eGet, eSet) = _symbol "Real64_Math_e": (unit -> (Real64.t)) * ((Real64.t) -> unit);
+val exp = _import "Real64_Math_exp" : Real64.t -> Real64.t;
+val ln = _import "Real64_Math_ln" : Real64.t -> Real64.t;
+val log10 = _import "Real64_Math_log10" : Real64.t -> Real64.t;
+val (piGet, piSet) = _symbol "Real64_Math_pi": (unit -> (Real64.t)) * ((Real64.t) -> unit);
+val pow = _import "Real64_Math_pow" : Real64.t * Real64.t -> Real64.t;
+val sin = _import "Real64_Math_sin" : Real64.t -> Real64.t;
+val sinh = _import "Real64_Math_sinh" : Real64.t -> Real64.t;
+val sqrt = _import "Real64_Math_sqrt" : Real64.t -> Real64.t;
+val tan = _import "Real64_Math_tan" : Real64.t -> Real64.t;
+val tanh = _import "Real64_Math_tanh" : Real64.t -> Real64.t;
+end
+val (maxFiniteGet, maxFiniteSet) = _symbol "Real64_maxFinite": (unit -> (Real64.t)) * ((Real64.t) -> unit);
+val (minNormalPosGet, minNormalPosSet) = _symbol "Real64_minNormalPos": (unit -> (Real64.t)) * ((Real64.t) -> unit);
+val (minPosGet, minPosSet) = _symbol "Real64_minPos": (unit -> (Real64.t)) * ((Real64.t) -> unit);
+val modf = _import "Real64_modf" : Real64.t * (Real64.t) ref -> Real64.t;
+val nextAfter = _import "Real64_nextAfter" : Real64.t * Real64.t -> Real64.t;
+val round = _import "Real64_round" : Real64.t -> Real64.t;
+val signBit = _import "Real64_signBit" : Real64.t -> C_Int.t;
+val strto = _import "Real64_strto" : NullString8.t -> Real64.t;
+end
 structure Socket = 
 struct
 val accept = _import "Socket_accept" : C_Sock.t * (Word8.t) array * (C_Socklen.t) ref -> (C_Int.t) C_Errno.t;

Added: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/check-pack-real.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/check-pack-real.sml	2006-04-25 17:35:46 UTC (rev 4415)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/check-pack-real.sml	2006-04-25 18:35:12 UTC (rev 4416)
@@ -0,0 +1,37 @@
+(* Copyright (C) 1999-2006 Henry Cejtin, Matthew Fluet, Suresh
+ *    Jagannathan, and Stephen Weeks.
+ * Copyright (C) 1997-2000 NEC Research Institute.
+ *
+ * MLton is released under a BSD-style license.
+ * See the file MLton-LICENSE for details.
+ *)
+
+local
+   fun 'a check (x: 'a, y: 'a) : unit = ()
+
+   local
+      structure PR1 = Primitive.PackReal32
+      structure PR2 = PrimitiveFFI.PackReal32
+   in
+      val () = check (PR1.subArr, PR2.subArr)
+      val () = check (PR1.subArrRev, PR2.subArrRev)
+      val () = check (PR1.subVec, PR2.subVec)
+      val () = check (PR1.subVecRev, PR2.subVecRev)
+      val () = check (PR1.update, PR2.update)
+      val () = check (PR1.updateRev, PR2.updateRev)
+   end
+
+   local
+      structure PR1 = Primitive.PackReal64
+      structure PR2 = PrimitiveFFI.PackReal64
+   in
+      val () = check (PR1.subArr, PR2.subArr)
+      val () = check (PR1.subArrRev, PR2.subArrRev)
+      val () = check (PR1.subVec, PR2.subVec)
+      val () = check (PR1.subVecRev, PR2.subVecRev)
+      val () = check (PR1.update, PR2.update)
+      val () = check (PR1.updateRev, PR2.updateRev)
+   end
+in
+
+end

Added: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/check-real.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/check-real.sml	2006-04-25 17:35:46 UTC (rev 4415)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/check-real.sml	2006-04-25 18:35:12 UTC (rev 4416)
@@ -0,0 +1,88 @@
+(* Copyright (C) 1999-2006 Henry Cejtin, Matthew Fluet, Suresh
+ *    Jagannathan, and Stephen Weeks.
+ * Copyright (C) 1997-2000 NEC Research Institute.
+ *
+ * MLton is released under a BSD-style license.
+ * See the file MLton-LICENSE for details.
+ *)
+
+local
+   fun 'a check (x: 'a, y: 'a) : unit = ()
+
+   local
+      structure R1 = Primitive.Real32
+      structure R2 = PrimitiveFFI.Real32
+   in
+      val () = check (R1.Math.acos, R2.Math.acos)
+      val () = check (R1.Math.asin, R2.Math.asin)
+      val () = check (R1.Math.atan, R2.Math.atan)
+      val () = check (R1.Math.atan2, R2.Math.atan2)
+      val () = check (R1.Math.cos, R2.Math.cos)
+      val () = check (R1.Math.cosh, R2.Math.cosh)
+      val () = check (fn () => R1.Math.e, R2.Math.eGet)
+      val () = check (R1.Math.exp, R2.Math.exp)
+      val () = check (R1.Math.ln, R2.Math.ln)
+      val () = check (R1.Math.log10, R2.Math.log10)
+      val () = check (fn () => R1.Math.pi, R2.Math.piGet)
+      val () = check (R1.Math.pow, R2.Math.pow)
+      val () = check (R1.Math.sin, R2.Math.sin)
+      val () = check (R1.Math.sinh, R2.Math.sinh)
+      val () = check (R1.Math.sqrt, R2.Math.sqrt)
+      val () = check (R1.Math.tan, R2.Math.tan)
+      val () = check (R1.Math.tanh, R2.Math.tanh)
+
+      val () = check (R1.abs, R2.abs)
+      val () = check (R1.class, R2.class)
+      val () = check (R1.frexp, R2.frexp)
+      val () = check (R1.gdtoa, R2.gdtoa)
+      val () = check (R1.ldexp, R2.ldexp)
+      val () = check (fn () => R1.maxFinite, R2.maxFiniteGet)
+      val () = check (fn () => R1.minNormalPos, R2.minNormalPosGet)
+      val () = check (fn () => R1.minPos, R2.minPosGet)
+      val () = check (R1.modf, R2.modf)
+      val () = check (R1.nextAfter, R2.nextAfter)
+      val () = check (R1.round, R2.round)
+      val () = check (R1.signBit, R2.signBit)
+      val () = check (R1.strto, R2.strto)
+   end
+
+   local
+      structure R1 = Primitive.Real64
+      structure R2 = PrimitiveFFI.Real64
+   in
+      val () = check (R1.Math.acos, R2.Math.acos)
+      val () = check (R1.Math.asin, R2.Math.asin)
+      val () = check (R1.Math.atan, R2.Math.atan)
+      val () = check (R1.Math.atan2, R2.Math.atan2)
+      val () = check (R1.Math.cos, R2.Math.cos)
+      val () = check (R1.Math.cosh, R2.Math.cosh)
+      val () = check (fn () => R1.Math.e, R2.Math.eGet)
+      val () = check (R1.Math.exp, R2.Math.exp)
+      val () = check (R1.Math.ln, R2.Math.ln)
+      val () = check (R1.Math.log10, R2.Math.log10)
+      val () = check (fn () => R1.Math.pi, R2.Math.piGet)
+      val () = check (R1.Math.pow, R2.Math.pow)
+      val () = check (R1.Math.sin, R2.Math.sin)
+      val () = check (R1.Math.sinh, R2.Math.sinh)
+      val () = check (R1.Math.sqrt, R2.Math.sqrt)
+      val () = check (R1.Math.tan, R2.Math.tan)
+      val () = check (R1.Math.tanh, R2.Math.tanh)
+
+      val () = check (R1.abs, R2.abs)
+      val () = check (R1.class, R2.class)
+      val () = check (R1.frexp, R2.frexp)
+      val () = check (R1.gdtoa, R2.gdtoa)
+      val () = check (R1.ldexp, R2.ldexp)
+      val () = check (fn () => R1.maxFinite, R2.maxFiniteGet)
+      val () = check (fn () => R1.minNormalPos, R2.minNormalPosGet)
+      val () = check (fn () => R1.minPos, R2.minPosGet)
+      val () = check (R1.modf, R2.modf)
+      val () = check (R1.nextAfter, R2.nextAfter)
+      val () = check (R1.round, R2.round)
+      val () = check (R1.signBit, R2.signBit)
+      val () = check (R1.strto, R2.strto)
+   end
+
+in
+
+end

Added: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/prim-pack-real.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/prim-pack-real.sml	2006-04-25 17:35:46 UTC (rev 4415)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/prim-pack-real.sml	2006-04-25 18:35:12 UTC (rev 4416)
@@ -0,0 +1,51 @@
+(* Copyright (C) 1999-2006 Henry Cejtin, Matthew Fluet, Suresh
+ *    Jagannathan, and Stephen Weeks.
+ * Copyright (C) 1997-2000 NEC Research Institute.
+ *
+ * MLton is released under a BSD-style license.
+ * See the file MLton-LICENSE for details.
+ *)
+
+(* Primitive names are special -- see atoms/prim.fun. *)
+
+structure Primitive = struct
+
+open Primitive
+
+structure PackReal32 =
+   struct
+      type real = Real32.real
+         
+      val subArr = 
+         _import "PackReal32_subArr": Word8.word array * C_Ptrdiff.t -> real;
+      val subArrRev = 
+         _import "PackReal32_subArrRev": Word8.word array * C_Ptrdiff.t -> real;
+      val subVec = 
+         _import "PackReal32_subVec": Word8.word vector * C_Ptrdiff.t -> real;
+      val subVecRev = 
+         _import "PackReal32_subVecRev": Word8.word vector * C_Ptrdiff.t -> real;
+      val update = 
+         _import "PackReal32_update": Word8.word array * C_Ptrdiff.t * real -> unit;
+      val updateRev = 
+         _import "PackReal32_updateRev": Word8.word array * C_Ptrdiff.t * real -> unit;
+   end
+
+structure PackReal64 =
+   struct
+      type real = Real64.real
+         
+      val subArr = 
+         _import "PackReal64_subArr": Word8.word array * C_Ptrdiff.t -> real;
+      val subArrRev = 
+         _import "PackReal64_subArrRev": Word8.word array * C_Ptrdiff.t -> real;
+      val subVec = 
+         _import "PackReal64_subVec": Word8.word vector * C_Ptrdiff.t -> real;
+      val subVecRev =
+         _import "PackReal64_subVecRev": Word8.word vector * C_Ptrdiff.t -> real;
+      val update =
+         _import "PackReal64_update": Word8.word array * C_Ptrdiff.t * real -> unit;
+      val updateRev =
+         _import "PackReal64_updateRev": Word8.word array * C_Ptrdiff.t * real -> unit;
+   end
+
+end

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/prim-real.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/prim-real.sml	2006-04-25 17:35:46 UTC (rev 4415)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/prim-real.sml	2006-04-25 18:35:12 UTC (rev 4416)
@@ -13,6 +13,7 @@
       type real
       type t = real
 
+      val realSize: Primitive.Int32.int
       val precision: Primitive.Int32.int
       val radix: Primitive.Int32.int
 
@@ -45,6 +46,7 @@
       val + : real * real -> real
       val - : real * real -> real
       val / : real * real -> real
+      val ~ : real -> real
       val < : real * real -> bool
       val <= : real * real -> bool
       val == : real * real -> bool
@@ -62,7 +64,6 @@
       val round: real -> real
       val signBit: real -> C_Int.t
       val strto: Primitive.NullString8.t -> real
-      val ~ : real -> real
 
       (* Integer to float; depends on rounding mode. *)
       val fromInt8Unsafe: Primitive.Int8.int -> real
@@ -93,6 +94,7 @@
    struct
       open Real32
          
+      val realSize : Int32.int = 32
       val precision : Int32.int = 24
       val radix : Int32.int = 2
 
@@ -174,6 +176,7 @@
    struct
       open Real64
 
+      val realSize : Int32.int = 64
       val precision : Int32.int = 53
       val radix : Int32.int = 2
          

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/primitive.mlb
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/primitive.mlb	2006-04-25 17:35:46 UTC (rev 4415)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/primitive.mlb	2006-04-25 18:35:12 UTC (rev 4416)
@@ -56,9 +56,14 @@
    prim-string.sml
 
    prim-real.sml
+   prim-pack-real.sml
 
    prim-mlton.sml
 
    basis-ffi.sml
    prim2.sml
+
+   (* Check compatibility between primitives and runtime functions. *)
+   check-real.sml
+   check-pack-real.sml
 end

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/primitive.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/primitive.sml	2006-04-25 17:35:46 UTC (rev 4415)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/primitive.sml	2006-04-25 18:35:12 UTC (rev 4416)
@@ -25,32 +25,6 @@
 structure Primitive =
    struct
 
-      structure PackReal32 =
-         struct
-            type real = Real32.real
-               
-            val subVec = _import "PackReal32_subVec": Word8.word vector * int -> real;
-            val subVecRev =
-               _import "PackReal32_subVecRev": Word8.word vector * int -> real;
-            val update =
-               _import "PackReal32_update": Word8.word array * int * real -> unit;
-            val updateRev =
-               _import "PackReal32_updateRev": Word8.word array * int * real -> unit;
-         end
-
-      structure PackReal64 =
-         struct
-            type real = Real64.real
-               
-            val subVec = _import "PackReal64_subVec": Word8.word vector * int -> real;
-            val subVecRev =
-               _import "PackReal64_subVecRev": Word8.word vector * int -> real;
-            val update =
-               _import "PackReal64_update": Word8.word array * int * real -> unit;
-            val updateRev =
-               _import "PackReal64_updateRev": Word8.word array * int * real -> unit;
-         end
-
       structure TextIO =
          struct
             val bufSize = _command_line_const "TextIO.bufSize": int = 4096;

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/real/pack-real.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/real/pack-real.sml	2006-04-25 17:35:46 UTC (rev 4415)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/real/pack-real.sml	2006-04-25 18:35:12 UTC (rev 4416)
@@ -8,71 +8,248 @@
 
 functor PackReal (S: sig
                         type real
-                        val bytesPerElem: int
+                        val realSize: int
                         val isBigEndian: bool
-                        val subVec: Word8.word vector * int -> real
-                        val subVecRev: Word8.word vector * int -> real
-                        val update: Word8.word array * int * real -> unit
-                        val updateRev: Word8.word array * int * real -> unit
+                        val subArr: Word8.word array * C_Ptrdiff.t -> real
+                        val subArrRev: Word8.word array * C_Ptrdiff.t -> real
+                        val subVec: Word8.word vector * C_Ptrdiff.t -> real
+                        val subVecRev: Word8.word vector * C_Ptrdiff.t -> real
+                        val update: Word8.word array * C_Ptrdiff.t * real -> unit
+                        val updateRev: Word8.word array * C_Ptrdiff.t * real -> unit
                      end): PACK_REAL =
 struct
 
 open S
 
-val (sub, up) =
+val bytesPerElem = Int.div (realSize, 8)
+
+val (subA, subV, updA) =
    if isBigEndian = Primitive.MLton.Platform.Arch.hostIsBigEndian
-      then (subVec, update)
-   else (subVecRev, updateRev)
+      then (subArr, subVec, update)
+   else (subArrRev, subVecRev, updateRev)
 
+fun offset (i, n) =
+   let
+      val i = Int.* (bytesPerElem, i)
+      val () =
+         if Primitive.Controls.safe
+            andalso (Int.geu (Int.+ (i, Int.- (bytesPerElem, 1)), n))
+            then raise Subscript
+            else ()
+   in
+      C_Ptrdiff.fromInt i
+   end
+   handle Overflow => raise Subscript
+
 fun update (a, i, r) =
    let
+      val i = offset (i, Word8Array.length a)
       val a = Word8Array.toPoly a
-      val _ = Array.checkSlice (a, i, SOME bytesPerElem)
    in
-      up (a, i, r)
+      updA (a, i, r)
    end
    
 local
-   val a = Word8Array.array (bytesPerElem, 0w0)
+   val a = Array.arrayUninit bytesPerElem
 in
    fun toBytes (r: real): Word8Vector.vector =
-      (up (Word8Array.toPoly a, 0, r)
-       ; Byte.stringToBytes (Byte.unpackString (Word8ArraySlice.full a)))
+      (updA (a, 0, r)
+       ; Word8Vector.fromPoly (Vector.fromArray a))
 end
 
+fun subArr (v, i) =
+   let
+      val i = offset (i, Word8Array.length v)
+      val v = Word8Array.toPoly v
+   in
+      subA (v, i)
+   end
+
 fun subVec (v, i) =
    let
+      val i = offset (i, Word8Vector.length v)
       val v = Word8Vector.toPoly v
-      val _ = Vector.checkSlice (v, i, SOME bytesPerElem)
    in
-      sub (v, i)
+      subV (v, i)
    end
 
 fun fromBytes v = subVec (v, 0)
 
-fun subArr (a, i) =
-   subVec (Word8Vector.fromPoly
-           (Primitive.Vector.fromArray (Word8Array.toPoly a)),
-           i)
-   
 end
 
 structure PackReal32Big: PACK_REAL =
-   PackReal (val bytesPerElem: int = 4
+   PackReal (val realSize = Real32.realSize
              val isBigEndian = true
              open Primitive.PackReal32)
 structure PackReal32Little: PACK_REAL =
-   PackReal (val bytesPerElem: int = 4
+   PackReal (val realSize = Real32.realSize
              val isBigEndian = false
              open Primitive.PackReal32)
 structure PackReal64Big: PACK_REAL =
-   PackReal (val bytesPerElem: int = 8
+   PackReal (val realSize = Real64.realSize
              val isBigEndian = true
              open Primitive.PackReal64)
 structure PackReal64Little: PACK_REAL =
-   PackReal (val bytesPerElem: int = 8
+   PackReal (val realSize = Real64.realSize
              val isBigEndian = false
              open Primitive.PackReal64)
+local
+   local
+      structure S =
+         Real_ChooseRealN
+         (type 'a t = int
+          val fReal32 = Real32.realSize
+          val fReal64 = Real64.realSize)
+   in
+      val realSize = S.f
+   end
 
-structure PackRealBig = PackReal64Big
-structure PackRealLittle = PackReal64Little
+   structure PackReal =
+      struct
+         type real = Real.real
+         local
+            structure S =
+               Real_ChooseRealN
+               (type 'a t = Word8.word array * C_Ptrdiff.t -> 'a
+                val fReal32 = Primitive.PackReal32.subArr
+                val fReal64 = Primitive.PackReal64.subArr)
+         in
+            val subArr = S.f
+         end
+         local
+            structure S =
+               Real_ChooseRealN
+               (type 'a t = Word8.word array * C_Ptrdiff.t -> 'a
+                val fReal32 = Primitive.PackReal32.subArrRev
+                val fReal64 = Primitive.PackReal64.subArrRev)
+         in
+            val subArrRev = S.f
+         end
+         local
+            structure S =
+               Real_ChooseRealN
+               (type 'a t = Word8.word vector * C_Ptrdiff.t -> 'a
+                val fReal32 = Primitive.PackReal32.subVec
+                val fReal64 = Primitive.PackReal64.subVec)
+         in
+            val subVec = S.f
+         end
+         local
+            structure S =
+               Real_ChooseRealN
+               (type 'a t = Word8.word vector * C_Ptrdiff.t -> 'a
+                val fReal32 = Primitive.PackReal32.subVecRev
+                val fReal64 = Primitive.PackReal64.subVecRev)
+         in
+            val subVecRev = S.f
+         end
+         local
+            structure S =
+               Real_ChooseRealN
+               (type 'a t = Word8.word array * C_Ptrdiff.t * 'a -> unit
+                val fReal32 = Primitive.PackReal32.update
+                val fReal64 = Primitive.PackReal64.update)
+         in
+            val update = S.f
+         end
+         local
+            structure S =
+               Real_ChooseRealN
+               (type 'a t = Word8.word array * C_Ptrdiff.t * 'a -> unit
+                val fReal32 = Primitive.PackReal32.updateRev
+                val fReal64 = Primitive.PackReal64.updateRev)
+         in
+            val updateRev = S.f
+         end
+
+      end
+in
+structure PackRealBig: PACK_REAL =
+   PackReal (val realSize = realSize
+             val isBigEndian = true
+             open PackReal)
+structure PackRealLittle: PACK_REAL =
+   PackReal (val realSize = realSize
+             val isBigEndian = false
+             open PackReal)
+end
+local
+   local
+      structure S =
+         LargeReal_ChooseRealN
+         (type 'a t = int
+          val fReal32 = Real32.realSize
+          val fReal64 = Real64.realSize)
+   in
+      val realSize = S.f
+   end
+
+   structure PackLargeReal =
+      struct
+         type real = LargeReal.real
+         local
+            structure S =
+               LargeReal_ChooseRealN
+               (type 'a t = Word8.word array * C_Ptrdiff.t -> 'a
+                val fReal32 = Primitive.PackReal32.subArr
+                val fReal64 = Primitive.PackReal64.subArr)
+         in
+            val subArr = S.f
+         end
+         local
+            structure S =
+               LargeReal_ChooseRealN
+               (type 'a t = Word8.word array * C_Ptrdiff.t -> 'a
+                val fReal32 = Primitive.PackReal32.subArrRev
+                val fReal64 = Primitive.PackReal64.subArrRev)
+         in
+            val subArrRev = S.f
+         end
+         local
+            structure S =
+               LargeReal_ChooseRealN
+               (type 'a t = Word8.word vector * C_Ptrdiff.t -> 'a
+                val fReal32 = Primitive.PackReal32.subVec
+                val fReal64 = Primitive.PackReal64.subVec)
+         in
+            val subVec = S.f
+         end
+         local
+            structure S =
+               LargeReal_ChooseRealN
+               (type 'a t = Word8.word vector * C_Ptrdiff.t -> 'a
+                val fReal32 = Primitive.PackReal32.subVecRev
+                val fReal64 = Primitive.PackReal64.subVecRev)
+         in
+            val subVecRev = S.f
+         end
+         local
+            structure S =
+               LargeReal_ChooseRealN
+               (type 'a t = Word8.word array * C_Ptrdiff.t * 'a -> unit
+                val fReal32 = Primitive.PackReal32.update
+                val fReal64 = Primitive.PackReal64.update)
+         in
+            val update = S.f
+         end
+         local
+            structure S =
+               LargeReal_ChooseRealN
+               (type 'a t = Word8.word array * C_Ptrdiff.t * 'a -> unit
+                val fReal32 = Primitive.PackReal32.updateRev
+                val fReal64 = Primitive.PackReal64.updateRev)
+         in
+            val updateRev = S.f
+         end
+
+      end
+in
+structure PackLargeRealBig: PACK_REAL =
+   PackReal (val realSize = realSize
+             val isBigEndian = true
+             open PackLargeReal)
+structure PackLargeRealLittle: PACK_REAL =
+   PackReal (val realSize = realSize
+             val isBigEndian = false
+             open PackLargeReal)
+end

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/real/real.sig
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/real/real.sig	2006-04-25 17:35:46 UTC (rev 4415)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/real/real.sig	2006-04-25 18:35:12 UTC (rev 4416)
@@ -27,6 +27,7 @@
       val minNormalPos: real
       val minPos: real
 
+      val realSize: Primitive.Int32.int
       val precision: Primitive.Int32.int
       val radix: Primitive.Int32.int
 
@@ -133,3 +134,9 @@
       val toString: real -> string
       val unordered: real * real -> bool
    end
+
+signature REAL_EXTRA =
+   sig
+      include REAL
+      val realSize: Int.int
+   end

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/real/real.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/real/real.sml	2006-04-25 17:35:46 UTC (rev 4415)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/real/real.sml	2006-04-25 18:35:12 UTC (rev 4416)
@@ -5,7 +5,7 @@
  * See the file MLton-LICENSE for details.
  *)
 
-functor Real (R: PRE_REAL): REAL =
+functor Real (R: PRE_REAL): REAL_EXTRA =
    struct
       structure MLton = Primitive.MLton
       structure Prim = R
@@ -46,6 +46,7 @@
          val minNormalPos = minNormalPos
          val minPos = minPos
 
+         val realSize = Primitive.Int32.toInt realSize
          val precision = Primitive.Int32.toInt precision
          val radix = Primitive.Int32.toInt radix
 

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/basis/Int/PackWord.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/basis/Int/PackWord.c	2006-04-25 17:35:46 UTC (rev 4415)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/Int/PackWord.c	2006-04-25 18:35:12 UTC (rev 4416)
@@ -4,7 +4,7 @@
 #define Vec(t) Vector(t)
 
 #define mkSubSeq(kind, Seq)                                             \
-Word##kind##_t PackWord##kind##_sub##Seq (Seq(Word8_t) seq, Int offset) { \
+Word##kind##_t PackWord##kind##_sub##Seq (Seq(Word8_t) seq, C_Ptrdiff_t offset) { \
   Word##kind##_t w;                                                     \
   pointer p = (pointer)&w;                                              \
   pointer s = (pointer)seq + ((kind / 8) * offset);                     \
@@ -15,7 +15,7 @@
   return w;                                                             \
 }
 #define mkSubSeqRev(kind, Seq)                                          \
-Word##kind##_t PackWord##kind##_sub##Seq##Rev (Seq(Word8_t) seq, Int offset) { \
+Word##kind##_t PackWord##kind##_sub##Seq##Rev (Seq(Word8_t) seq, C_Ptrdiff_t offset) { \
   Word##kind##_t w;                                                     \
   pointer p = (pointer)&w;                                              \
   pointer s = (pointer)seq + ((kind / 8) * offset);                     \
@@ -27,7 +27,7 @@
 }
 
 #define mkUpdate(kind)                                                  \
-void PackWord##kind##_update (Arr(Word8_t) a, Int offset, Word##kind##_t w) { \
+void PackWord##kind##_update (Arr(Word8_t) a, C_Ptrdiff_t offset, Word##kind##_t w) { \
   pointer p = (pointer)&w;                                              \
   pointer s = (pointer)a + ((kind / 8) * offset);                       \
   int i;                                                                \
@@ -36,7 +36,7 @@
     s[i] = p[i];                                                        \
 }
 #define mkUpdateRev(kind)                                               \
-void PackWord##kind##_updateRev (Arr(Word8_t) a, Int offset, Word##kind##_t w) { \
+void PackWord##kind##_updateRev (Arr(Word8_t) a, C_Ptrdiff_t offset, Word##kind##_t w) { \
   pointer p = (pointer)&w;                                              \
   pointer s = (pointer)a + ((kind / 8) * offset);                       \
   int i;                                                                \
@@ -63,14 +63,14 @@
 #undef all
 
 
-Word32_t Word8Array_subWord32Rev (Array(Word8_t) a, Int offset) {
+Word32_t Word8Array_subWord32Rev (Array(Word8_t) a, C_Ptrdiff_t offset) {
   return PackWord32_subArrRev (a, offset);
 }
 
-void Word8Array_updateWord32Rev (Array(Word32_t) a, Int offset, Word32_t w) {
+void Word8Array_updateWord32Rev (Array(Word32_t) a, C_Ptrdiff_t offset, Word32_t w) {
   PackWord32_updateRev (a, offset, w);
 }
 
-Word32_t Word8Vector_subWord32Rev (Vector(Word8_t) v, Int offset) {
+Word32_t Word8Vector_subWord32Rev (Vector(Word8_t) v, C_Ptrdiff_t offset) {
   return PackWord32_subArrRev (v, offset);
 }

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/Math.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/Math.c	2006-04-25 17:35:46 UTC (rev 4415)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/Math.c	2006-04-25 18:35:12 UTC (rev 4416)
@@ -1,11 +1,9 @@
 #include "platform.h"
 
 #define unaryReal(g, h)                                         \
-Real64_t Real64_##g (Real64_t x);                               \
 Real64_t Real64_##g (Real64_t x) {                              \
   return h (x);                                                 \
 }                                                               \
-Real32_t Real32_##g (Real32_t x);                               \
 Real32_t Real32_##g (Real32_t x) {                              \
   return h##f (x);                                              \
 }
@@ -14,11 +12,9 @@
 #undef unaryReal
 
 #define binaryReal(g, h)                                        \
-Real64_t Real64_Math_##g (Real64_t x, Real64_t y);              \
 Real64_t Real64_Math_##g (Real64_t x, Real64_t y) {             \
   return h (x, y);                                              \
 }                                                               \
-Real32_t Real32_Math_##g (Real32_t x, Real32_t y);              \
 Real32_t Real32_Math_##g (Real32_t x, Real32_t y) {             \
   return h##f (x, y);                                           \
 }
@@ -27,12 +23,10 @@
 #undef binaryReal
 
 #define unaryReal(g, h)                                         \
-Real64_t Real64_##g (Real64_t x);                               \
-Real64_t Real64_##g (Real64_t x) {                              \
+Real64_t Real64_Math_##g (Real64_t x) {                         \
   return h (x);                                                 \
 }                                                               \
-Real32_t Real32_##g (Real32_t x);                               \
-Real32_t Real32_##g (Real32_t x) {                              \
+Real32_t Real32_Math_##g (Real32_t x) {                         \
   return h##f (x);                                              \
 }
 unaryReal(acos, acos)
@@ -50,12 +44,12 @@
 unaryReal(tanh, tanh)
 #undef unaryReal
 
-Real64_t Real64_ldexp (Real64_t x, C_Int_t i);
-Real64_t Real64_ldexp (Real64_t x, C_Int_t i) {
-  return ldexp (x, i);
+#define binaryRealInt(g, h)                                     \
+Real64_t Real64_##g (Real64_t x, C_Int_t i) {                   \
+  return h (x, i);                                              \
+}                                                               \
+Real32_t Real32_##g (Real32_t x, C_Int_t i) {                   \
+  return h##f (x, i);                                           \
 }
-
-Real32_t Real32_ldexp (Real32_t x, C_Int_t i);
-Real32_t Real32_ldexp (Real32_t x, C_Int_t i) {
-  return ldexpf (x, i);
-}
+binaryRealInt(ldexp, ldexp)
+#undef binaryRealInt

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/PackReal.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/PackReal.c	2006-04-25 17:35:46 UTC (rev 4415)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/PackReal.c	2006-04-25 18:35:12 UTC (rev 4416)
@@ -4,10 +4,10 @@
 #define Vec(t) Vector(t)
 
 #define mkSubSeq(kind, Seq)                                             \
-Real##kind##_t PackReal##kind##_sub##Seq (Seq(Word8_t) seq, Int offset) { \
+Real##kind##_t PackReal##kind##_sub##Seq (Seq(Word8_t) seq, C_Ptrdiff_t offset) { \
   Real##kind##_t r;                                                     \
-  pointer p = (pointer)&r;                                              \
-  pointer s = (pointer)seq + offset;                                    \
+  Word8_t* p = (Word8_t*)&r;                                            \
+  Word8_t* s = (Word8_t*)seq + offset;                                  \
   int i;                                                                \
                                                                         \
   for (i = 0; i < kind / 8; ++i)                                        \
@@ -15,10 +15,10 @@
   return r;                                                             \
 }
 #define mkSubSeqRev(kind, Seq)                                          \
-Real##kind##_t PackReal##kind##_sub##Seq##Rev (Seq(Word8_t) seq, Int offset) { \
+Real##kind##_t PackReal##kind##_sub##Seq##Rev (Seq(Word8_t) seq, C_Ptrdiff_t offset) { \
   Real##kind##_t r;                                                     \
-  pointer p = (pointer)&r;                                              \
-  pointer s = (pointer)seq + offset;                                    \
+  Word8_t* p = (Word8_t*)&r;                                            \
+  Word8_t* s = (Word8_t*)seq + offset;                                  \
   int i;                                                                \
                                                                         \
   for (i = 0; i < kind / 8; ++i)                                        \
@@ -27,18 +27,18 @@
 }
 
 #define mkUpdate(kind)                                                  \
-void PackReal##kind##_update (Arr(Word8_t) a, Int offset, Real##kind##_t r) { \
-  pointer p = (pointer)&r;                                              \
-  pointer s = (pointer)a + offset;                                      \
+void PackReal##kind##_update (Arr(Word8_t) a, C_Ptrdiff_t offset, Real##kind##_t r) { \
+  Word8_t* p = (Word8_t*)&r;                                            \
+  Word8_t* s = (Word8_t*)a + offset;                                    \
   int i;                                                                \
                                                                         \
   for (i = 0; i < kind / 8; ++i)                                        \
     s[i] = p[i];                                                        \
 }
 #define mkUpdateRev(kind)                                               \
-void PackReal##kind##_updateRev (Arr(Word8_t) a, Int offset, Real##kind##_t r) { \
-  pointer p = (pointer)&r;                                              \
-  pointer s = (pointer)a + offset;                                      \
+void PackReal##kind##_updateRev (Arr(Word8_t) a, C_Ptrdiff_t offset, Real##kind##_t r) { \
+  Word8_t* p = (Word8_t*)&r;                                            \
+  Word8_t* s = (Word8_t*)a + offset;                                    \
   int i;                                                                \
                                                                         \
   for (i = 0; i < kind / 8; ++i)                                        \

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/class.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/class.c	2006-04-25 17:35:46 UTC (rev 4415)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/class.c	2006-04-25 18:35:12 UTC (rev 4416)
@@ -1,7 +1,5 @@
 #include "platform.h"
 
-C_Int_t Real32_class (Real32_t f);
-
 #if HAS_FPCLASSIFY
 
 C_Int_t Real32_class (Real32_t f) {
@@ -56,8 +54,6 @@
 #endif
 
 
-C_Int_t Real64_class (Real64_t d);
-
 #if HAS_FPCLASSIFY
 
 C_Int_t Real64_class (Real64_t d) {

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/frexp.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/frexp.c	2006-04-25 17:35:46 UTC (rev 4415)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/frexp.c	2006-04-25 18:35:12 UTC (rev 4416)
@@ -1,11 +1,11 @@
 #include "platform.h"
 
-Real32_t Real32_frexp (Real32_t x, Ref(C_Int_t) exp);
-Real32_t Real32_frexp (Real32_t x, Ref(C_Int_t) exp) {
-  return frexpf (x, (int*)exp);
+#define binaryRealIntRef(g, h)                                  \
+Real64_t Real64_##g (Real64_t x, Ref(C_Int_t) i) {              \
+  return h (x, (int*)i);                                        \
+}                                                               \
+Real32_t Real32_##g (Real32_t x, Ref(C_Int_t) i) {              \
+  return h##f (x, (int*)i);                                     \
 }
-
-Real64_t Real64_frexp (Real64_t x, Ref(C_Int_t) exp);
-Real64_t Real64_frexp (Real64_t x, Ref(C_Int_t) exp) {
-  return frexp (x, (int*)exp);
-}
+binaryRealIntRef(frexp, frexp)
+#undef binaryRealIntRef

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/gdtoa.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/gdtoa.c	2006-04-25 17:35:46 UTC (rev 4415)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/gdtoa.c	2006-04-25 18:35:12 UTC (rev 4416)
@@ -6,7 +6,6 @@
 #endif
 
 /* This code is patterned on g_dfmt from the gdtoa sources. */
-C_String_t Real32_gdtoa (Real32_t f, C_Int_t mode, C_Int_t ndig, Ref(C_Int_t) decpt);
 C_String_t Real32_gdtoa (Real32_t f, C_Int_t mode, C_Int_t ndig, Ref(C_Int_t) decpt) {
   ULong bits[1];
   int ex;
@@ -40,7 +39,6 @@
   return (C_String_t)result;
 }
 
-C_String_t Real64_gdtoa (Real64_t d, C_Int_t mode, C_Int_t ndig, Ref(C_Int_t) decpt);
 C_String_t Real64_gdtoa (Real64_t d, C_Int_t mode, C_Int_t ndig, Ref(C_Int_t) decpt) {
   ULong bits[2];
   int ex;

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/modf.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/modf.c	2006-04-25 17:35:46 UTC (rev 4415)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/modf.c	2006-04-25 18:35:12 UTC (rev 4416)
@@ -1,11 +1,11 @@
 #include "platform.h"
 
-Real64_t Real64_modf (Real64_t x, Ref(Real64_t) exp);
-Real64_t Real64_modf (Real64_t x, Ref(Real64_t) exp) {
-  return modf (x, (Real64_t*)exp);
+#define binaryRealRealRef(g, h)                                 \
+Real64_t Real64_##g (Real64_t x, Ref(Real64_t) yp) {            \
+  return h (x, (Real64_t*)yp);                                  \
+}                                                               \
+Real32_t Real32_##g (Real32_t x, Ref(Real32_t) yp) {            \
+  return h##f (x, (Real32_t*)yp);                               \
 }
-
-Real32_t Real32_modf (Real32_t x, Ref(Real32_t) exp);
-Real32_t Real32_modf (Real32_t x, Ref(Real32_t) exp) {
-  return modff (x, (Real32_t*)exp);
-}
+binaryRealRealRef(modf, modf)
+#undef binaryRealRealRef

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/nextAfter.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/nextAfter.c	2006-04-25 17:35:46 UTC (rev 4415)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/nextAfter.c	2006-04-25 18:35:12 UTC (rev 4416)
@@ -1,12 +1,10 @@
 #include "platform.h"
 
 /* nextafter is a macro, so we must have a C wrapper to work correctly. */
-Real32_t Real32_nextAfter (Real32_t x1, Real32_t x2);
 Real32_t Real32_nextAfter (Real32_t x1, Real32_t x2) {
   return nextafterf (x1, x2);
 }
 
-Real64_t Real64_nextAfter (Real64_t x1, Real64_t x2);
 Real64_t Real64_nextAfter (Real64_t x1, Real64_t x2) {
   return nextafter (x1, x2);
 }

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/signBit.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/signBit.c	2006-04-25 17:35:46 UTC (rev 4415)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/signBit.c	2006-04-25 18:35:12 UTC (rev 4416)
@@ -1,8 +1,5 @@
 #include "platform.h"
 
-C_Int_t Real32_signBit (Real32_t f);
-C_Int_t Real64_signBit (Real64_t d);
-
 #if HAS_SIGNBIT
 
 C_Int_t Real32_signBit (Real32_t f) {

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/strto.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/strto.c	2006-04-25 17:35:46 UTC (rev 4415)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/strto.c	2006-04-25 18:35:12 UTC (rev 4416)
@@ -3,7 +3,6 @@
 Real32_t gdtoa_strtof (char *s, char **endptr);
 Real64_t gdtoa_strtod (char *s, char **endptr);
 
-Real32_t Real32_strto (NullString8_t s);
 Real32_t Real32_strto (NullString8_t s) {
   char *endptr;
   Real32_t res;
@@ -13,10 +12,9 @@
   return res;
 }
 
-Real64_t Real64_strto (NullString8_t s);
 Real64_t Real64_strto (NullString8_t s) {
   char *endptr;
-  Real64 res;
+  Real64_t res;
   
   res = gdtoa_strtod ((char*)s, &endptr);
   assert (NULL != endptr);

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gen/basis-ffi.def
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gen/basis-ffi.def	2006-04-25 17:35:46 UTC (rev 4415)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gen/basis-ffi.def	2006-04-25 18:35:12 UTC (rev 4416)
@@ -1,6 +1,3 @@
-# Posix.FileSys.PC.2_SYMLINKS = _const : C_Int.t
-# Posix.FileSys.Stat.getBlkCnt = _import : unit -> C_BlkCnt.t
-# Posix.FileSys.Stat.getBlkSize = _import : unit -> C_BlkSize.t
 CommandLine.argc = _symbol : C_Int.t
 CommandLine.argv = _symbol : C_StringArray.t
 CommandLine.commandName = _symbol : C_String.t
@@ -139,6 +136,18 @@
 OS.IO.POLLOUT = _const : C_Short.t
 OS.IO.POLLPRI = _const : C_Short.t
 OS.IO.poll = _import : C_Fd.t vector * C_Short.t vector * C_NFds.t * C_Int.t * C_Short.t array -> C_Int.t C_Errno.t
+PackReal32.subArr = _import : Word8.t array * C_Ptrdiff.t -> Real32.t
+PackReal32.subArrRev = _import : Word8.t array * C_Ptrdiff.t -> Real32.t
+PackReal32.subVec = _import : Word8.t vector * C_Ptrdiff.t -> Real32.t
+PackReal32.subVecRev = _import : Word8.t vector * C_Ptrdiff.t -> Real32.t
+PackReal32.update = _import : Word8.t array * C_Ptrdiff.t * Real32.t -> unit
+PackReal32.updateRev = _import : Word8.t array * C_Ptrdiff.t * Real32.t -> unit
+PackReal64.subArr = _import : Word8.t array * C_Ptrdiff.t -> Real64.t
+PackReal64.subArrRev = _import : Word8.t array * C_Ptrdiff.t -> Real64.t
+PackReal64.subVec = _import : Word8.t vector * C_Ptrdiff.t -> Real64.t
+PackReal64.subVecRev = _import : Word8.t vector * C_Ptrdiff.t -> Real64.t
+PackReal64.update = _import : Word8.t array * C_Ptrdiff.t * Real64.t -> unit
+PackReal64.updateRev = _import : Word8.t array * C_Ptrdiff.t * Real64.t -> unit
 Posix.Error.E2BIG = _const : C_Int.t
 Posix.Error.EACCES = _const : C_Int.t
 Posix.Error.EADDRINUSE = _const : C_Int.t
@@ -243,6 +252,7 @@
 Posix.FileSys.O.TEXT = _const : C_Int.t
 Posix.FileSys.O.TRUNC = _const : C_Int.t
 Posix.FileSys.O.WRONLY = _const : C_Int.t
+# Posix.FileSys.PC.2_SYMLINKS = _const : C_Int.t
 Posix.FileSys.PC.ALLOC_SIZE_MIN = _const : C_Int.t
 Posix.FileSys.PC.ASYNC_IO = _const : C_Int.t
 Posix.FileSys.PC.CHOWN_RESTRICTED = _const : C_Int.t
@@ -294,6 +304,8 @@
 Posix.FileSys.ST.isSock = _import : C_Mode.t -> Bool.t
 Posix.FileSys.Stat.fstat = _import : C_Fd.t -> C_Int.t C_Errno.t
 Posix.FileSys.Stat.getATime = _import : unit -> C_Time.t
+# Posix.FileSys.Stat.getBlkCnt = _import : unit -> C_BlkCnt.t
+# Posix.FileSys.Stat.getBlkSize = _import : unit -> C_BlkSize.t
 Posix.FileSys.Stat.getCTime = _import : unit -> C_Time.t
 Posix.FileSys.Stat.getDev = _import : unit -> C_Dev.t
 Posix.FileSys.Stat.getGId = _import : unit -> C_GId.t
@@ -736,6 +748,66 @@
 Posix.TTY.V.VSTOP = _const : C_Int.t
 Posix.TTY.V.VSUSP = _const : C_Int.t
 Posix.TTY.V.VTIME = _const : C_Int.t
+Real32.Math.acos = _import : Real32.t -> Real32.t
+Real32.Math.asin = _import : Real32.t -> Real32.t
+Real32.Math.atan = _import : Real32.t -> Real32.t
+Real32.Math.atan2 = _import : Real32.t * Real32.t -> Real32.t
+Real32.Math.cos = _import : Real32.t -> Real32.t
+Real32.Math.cosh = _import : Real32.t -> Real32.t
+Real32.Math.e = _symbol : Real32.t
+Real32.Math.exp = _import : Real32.t -> Real32.t
+Real32.Math.ln = _import : Real32.t -> Real32.t
+Real32.Math.log10 = _import : Real32.t -> Real32.t
+Real32.Math.pi = _symbol : Real32.t
+Real32.Math.pow = _import : Real32.t * Real32.t -> Real32.t
+Real32.Math.sin = _import : Real32.t -> Real32.t
+Real32.Math.sinh = _import : Real32.t -> Real32.t
+Real32.Math.sqrt = _import : Real32.t -> Real32.t
+Real32.Math.tan = _import : Real32.t -> Real32.t
+Real32.Math.tanh = _import : Real32.t -> Real32.t
+Real32.abs = _import : Real32.t -> Real32.t
+Real32.class = _import : Real32.t -> C_Int.t
+Real32.frexp = _import : Real32.t * C_Int.t ref -> Real32.t
+Real32.gdtoa = _import : Real32.t * C_Int.t * C_Int.t * C_Int.t ref -> C_String.t
+Real32.ldexp = _import : Real32.t * C_Int.t -> Real32.t
+Real32.maxFinite = _symbol : Real32.t
+Real32.minNormalPos = _symbol : Real32.t
+Real32.minPos = _symbol : Real32.t
+Real32.modf = _import : Real32.t * Real32.t ref -> Real32.t
+Real32.nextAfter = _import : Real32.t * Real32.t -> Real32.t
+Real32.round = _import : Real32.t -> Real32.t
+Real32.signBit = _import : Real32.t -> C_Int.t
+Real32.strto = _import : NullString8.t -> Real32.t
+Real64.Math.acos = _import : Real64.t -> Real64.t
+Real64.Math.asin = _import : Real64.t -> Real64.t
+Real64.Math.atan = _import : Real64.t -> Real64.t
+Real64.Math.atan2 = _import : Real64.t * Real64.t -> Real64.t
+Real64.Math.cos = _import : Real64.t -> Real64.t
+Real64.Math.cosh = _import : Real64.t -> Real64.t
+Real64.Math.e = _symbol : Real64.t
+Real64.Math.exp = _import : Real64.t -> Real64.t
+Real64.Math.ln = _import : Real64.t -> Real64.t
+Real64.Math.log10 = _import : Real64.t -> Real64.t
+Real64.Math.pi = _symbol : Real64.t
+Real64.Math.pow = _import : Real64.t * Real64.t -> Real64.t
+Real64.Math.sin = _import : Real64.t -> Real64.t
+Real64.Math.sinh = _import : Real64.t -> Real64.t
+Real64.Math.sqrt = _import : Real64.t -> Real64.t
+Real64.Math.tan = _import : Real64.t -> Real64.t
+Real64.Math.tanh = _import : Real64.t -> Real64.t
+Real64.abs = _import : Real64.t -> Real64.t
+Real64.class = _import : Real64.t -> C_Int.t
+Real64.frexp = _import : Real64.t * C_Int.t ref -> Real64.t
+Real64.gdtoa = _import : Real64.t * C_Int.t * C_Int.t * C_Int.t ref -> C_String.t
+Real64.ldexp = _import : Real64.t * C_Int.t -> Real64.t
+Real64.maxFinite = _symbol : Real64.t
+Real64.minNormalPos = _symbol : Real64.t
+Real64.minPos = _symbol : Real64.t
+Real64.modf = _import : Real64.t * Real64.t ref -> Real64.t
+Real64.nextAfter = _import : Real64.t * Real64.t -> Real64.t
+Real64.round = _import : Real64.t -> Real64.t
+Real64.signBit = _import : Real64.t -> C_Int.t
+Real64.strto = _import : NullString8.t -> Real64.t
 Socket.AF.INET = _const : C_Int.t
 Socket.AF.INET6 = _const : C_Int.t
 Socket.AF.UNIX = _const : C_Int.t

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/platform.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/platform.h	2006-04-25 17:35:46 UTC (rev 4415)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/platform.h	2006-04-25 18:35:12 UTC (rev 4416)
@@ -185,23 +185,6 @@
 extern Bool MLton_Platform_CygwinUseMmap;
 
 /* ------------------------------------------------- */
-/*                     PackReal                      */
-/* ------------------------------------------------- */
-
-Real32_t PackReal32_subArr (Array(Word8_t) v, Int offset);
-Real32_t PackReal32_subArrRev (Array(Word8_t) v, Int offset);
-Real64_t PackReal64_subArr (Array(Word8_t) v, Int offset);
-Real64_t PackReal64_subArrRev (Array(Word8_t) v, Int offset);
-Real32_t PackReal32_subVec (Vector(Word8_t) v, Int offset);
-Real32_t PackReal32_subVecRev (Vector(Word8_t) v, Int offset);
-Real64_t PackReal64_subVec (Vector(Word8_t) v, Int offset);
-Real64_t PackReal64_subVecRev (Vector(Word8_t) v, Int offset);
-void PackReal32_update (Array(Word8_t) a, Int offset, Real32_t r);
-void PackReal32_updateRev (Array(Word8_t) a, Int offset, Real32_t r);
-void PackReal64_update (Array(Word8_t) a, Int offset, Real64_t r);
-void PackReal64_updateRev (Array(Word8_t) a, Int offset, Real64_t r);
-
-/* ------------------------------------------------- */
 /*                     PackWord                      */
 /* ------------------------------------------------- */