[MLton-commit] r4564
Matthew Fluet
MLton@mlton.org
Mon, 22 May 2006 08:56:52 -0700
Allow the C-side implementation of primitives to be shared among
libmlton, C-codegen headers, and Bytecode-codgen implementation.
----------------------------------------------------------------------
U mlton/branches/on-20050822-x86_64-branch/Makefile
U mlton/branches/on-20050822-x86_64-branch/basis-library/primitive/basis-ffi.sml
U mlton/branches/on-20050822-x86_64-branch/basis-library/primitive/check-real.sml
U mlton/branches/on-20050822-x86_64-branch/bytecode/interpret.c
U mlton/branches/on-20050822-x86_64-branch/include/bytecode-main.h
U mlton/branches/on-20050822-x86_64-branch/include/c-chunk.h
U mlton/branches/on-20050822-x86_64-branch/runtime/Makefile
A mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/Math-fns.h
U mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/Math.c
A mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/Real-consts.c
A mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/Real-ops.h
U mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/Real.c
D mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/frexp.c
A mlton/branches/on-20050822-x86_64-branch/runtime/basis/Word/Word-check.h
A mlton/branches/on-20050822-x86_64-branch/runtime/basis/Word/Word-consts.h
A mlton/branches/on-20050822-x86_64-branch/runtime/basis/Word/Word-ops.h
U mlton/branches/on-20050822-x86_64-branch/runtime/basis/Word/Word.c
A mlton/branches/on-20050822-x86_64-branch/runtime/basis/coerce.c
A mlton/branches/on-20050822-x86_64-branch/runtime/basis/coerce.h
U mlton/branches/on-20050822-x86_64-branch/runtime/gen/basis-ffi.def
U mlton/branches/on-20050822-x86_64-branch/runtime/gen/gen-basis-ffi.sml
U mlton/branches/on-20050822-x86_64-branch/runtime/platform.h
----------------------------------------------------------------------
Modified: mlton/branches/on-20050822-x86_64-branch/Makefile
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/Makefile 2006-05-21 23:07:23 UTC (rev 4563)
+++ mlton/branches/on-20050822-x86_64-branch/Makefile 2006-05-22 15:56:43 UTC (rev 4564)
@@ -286,13 +286,11 @@
basis-library/config/c/$(TARGET_ARCH)-$(TARGET_OS)/c-types.sml
cp runtime/gen/basis-ffi.sml \
basis-library/primitive/basis-ffi.sml
- mkdir -p "$(INC)/gc"
- mkdir -p "$(INC)/util"
- mkdir -p "$(INC)/platform"
$(CP) runtime/*.h "$(INC)/"
- $(CP) runtime/gc/*.h "$(INC)/gc"
- $(CP) runtime/util/*.h "$(INC)/util"
- $(CP) runtime/platform/*.h "$(INC)/platform"
+ for d in basis basis/Real basis/Word gc platform util; do \
+ mkdir -p "$(INC)/$$d"; \
+ $(CP) runtime/$$d/*.h "$(INC)/$$d"; \
+ done
$(CP) bytecode/interpret.h "$(INC)"
$(MAKE) -C bytecode
bytecode/print-opcodes >"$(LIB)/opcodes"
@@ -331,7 +329,7 @@
@echo 'Instantiating version numbers.'
for f in \
package/debian/changelog \
- "$(SPEC)" \
+ "$(SPEC)" \
package/freebsd/Makefile \
mlton/control/control-flags.sml; \
do \
Modified: mlton/branches/on-20050822-x86_64-branch/basis-library/primitive/basis-ffi.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library/primitive/basis-ffi.sml 2006-05-21 23:07:23 UTC (rev 4563)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/primitive/basis-ffi.sml 2006-05-22 15:56:43 UTC (rev 4564)
@@ -951,11 +951,17 @@
end
structure Real32 =
struct
+type t = Real32.t
val abs = _import "Real32_abs" : Real32.t -> Real32.t;
+val add = _import "Real32_add" : Real32.t * Real32.t -> Real32.t;
val class = _import "Real32_class" : Real32.t -> C_Int.t;
+val div = _import "Real32_div" : Real32.t * Real32.t -> Real32.t;
+val equal = _import "Real32_equal" : Real32.t * Real32.t -> Bool.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;
+val le = _import "Real32_le" : Real32.t * Real32.t -> Bool.t;
+val lt = _import "Real32_lt" : Real32.t * Real32.t -> Bool.t;
structure Math =
struct
val acos = _import "Real32_Math_acos" : Real32.t -> Real32.t;
@@ -980,18 +986,39 @@
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 mul = _import "Real32_mul" : Real32.t * Real32.t -> Real32.t;
+val muladd = _import "Real32_muladd" : Real32.t * Real32.t * Real32.t -> Real32.t;
+val mulsub = _import "Real32_mulsub" : Real32.t * Real32.t * Real32.t -> Real32.t;
+val neg = _import "Real32_neg" : Real32.t -> 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;
+val sub = _import "Real32_sub" : Real32.t * Real32.t -> Real32.t;
+val toReal32 = _import "Real32_toReal32" : Real32.t -> Real32.t;
+val toReal64 = _import "Real32_toReal64" : Real32.t -> Real64.t;
+val toWordS16 = _import "Real32_toWordS16" : Real32.t -> Int16.t;
+val toWordS32 = _import "Real32_toWordS32" : Real32.t -> Int32.t;
+val toWordS64 = _import "Real32_toWordS64" : Real32.t -> Int64.t;
+val toWordS8 = _import "Real32_toWordS8" : Real32.t -> Int8.t;
+val toWordU16 = _import "Real32_toWordU16" : Real32.t -> Word16.t;
+val toWordU32 = _import "Real32_toWordU32" : Real32.t -> Word32.t;
+val toWordU64 = _import "Real32_toWordU64" : Real32.t -> Word64.t;
+val toWordU8 = _import "Real32_toWordU8" : Real32.t -> Word8.t;
end
structure Real64 =
struct
+type t = Real64.t
val abs = _import "Real64_abs" : Real64.t -> Real64.t;
+val add = _import "Real64_add" : Real64.t * Real64.t -> Real64.t;
val class = _import "Real64_class" : Real64.t -> C_Int.t;
+val div = _import "Real64_div" : Real64.t * Real64.t -> Real64.t;
+val equal = _import "Real64_equal" : Real64.t * Real64.t -> Bool.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;
+val le = _import "Real64_le" : Real64.t * Real64.t -> Bool.t;
+val lt = _import "Real64_lt" : Real64.t * Real64.t -> Bool.t;
structure Math =
struct
val acos = _import "Real64_Math_acos" : Real64.t -> Real64.t;
@@ -1016,10 +1043,25 @@
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 mul = _import "Real64_mul" : Real64.t * Real64.t -> Real64.t;
+val muladd = _import "Real64_muladd" : Real64.t * Real64.t * Real64.t -> Real64.t;
+val mulsub = _import "Real64_mulsub" : Real64.t * Real64.t * Real64.t -> Real64.t;
+val neg = _import "Real64_neg" : Real64.t -> 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;
+val sub = _import "Real64_sub" : Real64.t * Real64.t -> Real64.t;
+val toReal32 = _import "Real64_toReal32" : Real64.t -> Real32.t;
+val toReal64 = _import "Real64_toReal64" : Real64.t -> Real64.t;
+val toWordS16 = _import "Real64_toWordS16" : Real64.t -> Int16.t;
+val toWordS32 = _import "Real64_toWordS32" : Real64.t -> Int32.t;
+val toWordS64 = _import "Real64_toWordS64" : Real64.t -> Int64.t;
+val toWordS8 = _import "Real64_toWordS8" : Real64.t -> Int8.t;
+val toWordU16 = _import "Real64_toWordU16" : Real64.t -> Word16.t;
+val toWordU32 = _import "Real64_toWordU32" : Real64.t -> Word32.t;
+val toWordU64 = _import "Real64_toWordU64" : Real64.t -> Word64.t;
+val toWordU8 = _import "Real64_toWordU8" : Real64.t -> Word8.t;
end
structure Socket =
struct
@@ -1135,5 +1177,225 @@
val terminate = _import "Windows_Process_terminate" : C_PId.t * C_Signal.t -> (C_Int.t) C_Errno.t;
end
end
+structure Word16 =
+struct
+type t = Word16.t
+val add = _import "Word16_add" : Word16.t * Word16.t -> Word16.t;
+val andb = _import "Word16_andb" : Word16.t * Word16.t -> Word16.t;
+val equal = _import "Word16_equal" : Word16.t * Word16.t -> Bool.t;
+val lshift = _import "Word16_lshift" : Word16.t * Word32.t -> Word16.t;
+val neg = _import "Word16_neg" : Word16.t -> Word16.t;
+val notb = _import "Word16_notb" : Word16.t -> Word16.t;
+val orb = _import "Word16_orb" : Word16.t * Word16.t -> Word16.t;
+val rol = _import "Word16_rol" : Word16.t * Word32.t -> Word16.t;
+val ror = _import "Word16_ror" : Word16.t * Word32.t -> Word16.t;
+val sub = _import "Word16_sub" : Word16.t * Word16.t -> Word16.t;
+val xorb = _import "Word16_xorb" : Word16.t * Word16.t -> Word16.t;
end
+structure Word32 =
+struct
+type t = Word32.t
+val add = _import "Word32_add" : Word32.t * Word32.t -> Word32.t;
+val andb = _import "Word32_andb" : Word32.t * Word32.t -> Word32.t;
+val equal = _import "Word32_equal" : Word32.t * Word32.t -> Bool.t;
+val lshift = _import "Word32_lshift" : Word32.t * Word32.t -> Word32.t;
+val neg = _import "Word32_neg" : Word32.t -> Word32.t;
+val notb = _import "Word32_notb" : Word32.t -> Word32.t;
+val orb = _import "Word32_orb" : Word32.t * Word32.t -> Word32.t;
+val rol = _import "Word32_rol" : Word32.t * Word32.t -> Word32.t;
+val ror = _import "Word32_ror" : Word32.t * Word32.t -> Word32.t;
+val sub = _import "Word32_sub" : Word32.t * Word32.t -> Word32.t;
+val xorb = _import "Word32_xorb" : Word32.t * Word32.t -> Word32.t;
end
+structure Word64 =
+struct
+type t = Word64.t
+val add = _import "Word64_add" : Word64.t * Word64.t -> Word64.t;
+val andb = _import "Word64_andb" : Word64.t * Word64.t -> Word64.t;
+val equal = _import "Word64_equal" : Word64.t * Word64.t -> Bool.t;
+val lshift = _import "Word64_lshift" : Word64.t * Word32.t -> Word64.t;
+val neg = _import "Word64_neg" : Word64.t -> Word64.t;
+val notb = _import "Word64_notb" : Word64.t -> Word64.t;
+val orb = _import "Word64_orb" : Word64.t * Word64.t -> Word64.t;
+val rol = _import "Word64_rol" : Word64.t * Word32.t -> Word64.t;
+val ror = _import "Word64_ror" : Word64.t * Word32.t -> Word64.t;
+val sub = _import "Word64_sub" : Word64.t * Word64.t -> Word64.t;
+val xorb = _import "Word64_xorb" : Word64.t * Word64.t -> Word64.t;
+end
+structure Word8 =
+struct
+type t = Word8.t
+val add = _import "Word8_add" : Word8.t * Word8.t -> Word8.t;
+val andb = _import "Word8_andb" : Word8.t * Word8.t -> Word8.t;
+val equal = _import "Word8_equal" : Word8.t * Word8.t -> Bool.t;
+val lshift = _import "Word8_lshift" : Word8.t * Word32.t -> Word8.t;
+val neg = _import "Word8_neg" : Word8.t -> Word8.t;
+val notb = _import "Word8_notb" : Word8.t -> Word8.t;
+val orb = _import "Word8_orb" : Word8.t * Word8.t -> Word8.t;
+val rol = _import "Word8_rol" : Word8.t * Word32.t -> Word8.t;
+val ror = _import "Word8_ror" : Word8.t * Word32.t -> Word8.t;
+val sub = _import "Word8_sub" : Word8.t * Word8.t -> Word8.t;
+val xorb = _import "Word8_xorb" : Word8.t * Word8.t -> Word8.t;
+end
+structure WordS16 =
+struct
+val addCheckOverflows = _import "WordS16_addCheckOverflows" : Int16.t * Int16.t -> Bool.t;
+val ge = _import "WordS16_ge" : Int16.t * Int16.t -> Bool.t;
+val gt = _import "WordS16_gt" : Int16.t * Int16.t -> Bool.t;
+val le = _import "WordS16_le" : Int16.t * Int16.t -> Bool.t;
+val lt = _import "WordS16_lt" : Int16.t * Int16.t -> Bool.t;
+val mul = _import "WordS16_mul" : Int16.t * Int16.t -> Int16.t;
+val mulCheckOverflows = _import "WordS16_mulCheckOverflows" : Int16.t * Int16.t -> Bool.t;
+val negCheckOverflows = _import "WordS16_negCheckOverflows" : Int16.t -> Bool.t;
+val quot = _import "WordS16_quot" : Int16.t * Int16.t -> Int16.t;
+val rem = _import "WordS16_rem" : Int16.t * Int16.t -> Int16.t;
+val rshift = _import "WordS16_rshift" : Int16.t * Word32.t -> Int16.t;
+val subCheckOverflows = _import "WordS16_subCheckOverflows" : Int16.t * Int16.t -> Bool.t;
+val toReal32 = _import "WordS16_toReal32" : Int16.t -> Real32.t;
+val toReal64 = _import "WordS16_toReal64" : Int16.t -> Real64.t;
+val toWord16 = _import "WordS16_toWord16" : Int16.t -> Word16.t;
+val toWord32 = _import "WordS16_toWord32" : Int16.t -> Word32.t;
+val toWord64 = _import "WordS16_toWord64" : Int16.t -> Word64.t;
+val toWord8 = _import "WordS16_toWord8" : Int16.t -> Word8.t;
+end
+structure WordS32 =
+struct
+val addCheckOverflows = _import "WordS32_addCheckOverflows" : Int32.t * Int32.t -> Bool.t;
+val ge = _import "WordS32_ge" : Int32.t * Int32.t -> Bool.t;
+val gt = _import "WordS32_gt" : Int32.t * Int32.t -> Bool.t;
+val le = _import "WordS32_le" : Int32.t * Int32.t -> Bool.t;
+val lt = _import "WordS32_lt" : Int32.t * Int32.t -> Bool.t;
+val mul = _import "WordS32_mul" : Int32.t * Int32.t -> Int32.t;
+val mulCheckOverflows = _import "WordS32_mulCheckOverflows" : Int32.t * Int32.t -> Bool.t;
+val negCheckOverflows = _import "WordS32_negCheckOverflows" : Int32.t -> Bool.t;
+val quot = _import "WordS32_quot" : Int32.t * Int32.t -> Int32.t;
+val rem = _import "WordS32_rem" : Int32.t * Int32.t -> Int32.t;
+val rshift = _import "WordS32_rshift" : Int32.t * Word32.t -> Int32.t;
+val subCheckOverflows = _import "WordS32_subCheckOverflows" : Int32.t * Int32.t -> Bool.t;
+val toReal32 = _import "WordS32_toReal32" : Int32.t -> Real32.t;
+val toReal64 = _import "WordS32_toReal64" : Int32.t -> Real64.t;
+val toWord16 = _import "WordS32_toWord16" : Int32.t -> Word16.t;
+val toWord32 = _import "WordS32_toWord32" : Int32.t -> Word32.t;
+val toWord64 = _import "WordS32_toWord64" : Int32.t -> Word64.t;
+val toWord8 = _import "WordS32_toWord8" : Int32.t -> Word8.t;
+end
+structure WordS64 =
+struct
+val addCheckOverflows = _import "WordS64_addCheckOverflows" : Int64.t * Int64.t -> Bool.t;
+val ge = _import "WordS64_ge" : Int64.t * Int64.t -> Bool.t;
+val gt = _import "WordS64_gt" : Int64.t * Int64.t -> Bool.t;
+val le = _import "WordS64_le" : Int64.t * Int64.t -> Bool.t;
+val lt = _import "WordS64_lt" : Int64.t * Int64.t -> Bool.t;
+val mul = _import "WordS64_mul" : Int64.t * Int64.t -> Int64.t;
+val mulCheckOverflows = _import "WordS64_mulCheckOverflows" : Int64.t * Int64.t -> Bool.t;
+val negCheckOverflows = _import "WordS64_negCheckOverflows" : Int64.t -> Bool.t;
+val quot = _import "WordS64_quot" : Int64.t * Int64.t -> Int64.t;
+val rem = _import "WordS64_rem" : Int64.t * Int64.t -> Int64.t;
+val rshift = _import "WordS64_rshift" : Int64.t * Word32.t -> Int64.t;
+val subCheckOverflows = _import "WordS64_subCheckOverflows" : Int64.t * Int64.t -> Bool.t;
+val toReal32 = _import "WordS64_toReal32" : Int64.t -> Real32.t;
+val toReal64 = _import "WordS64_toReal64" : Int64.t -> Real64.t;
+val toWord16 = _import "WordS64_toWord16" : Int64.t -> Word16.t;
+val toWord32 = _import "WordS64_toWord32" : Int64.t -> Word32.t;
+val toWord64 = _import "WordS64_toWord64" : Int64.t -> Word64.t;
+val toWord8 = _import "WordS64_toWord8" : Int64.t -> Word8.t;
+end
+structure WordS8 =
+struct
+val addCheckOverflows = _import "WordS8_addCheckOverflows" : Int8.t * Int8.t -> Bool.t;
+val ge = _import "WordS8_ge" : Int8.t * Int8.t -> Bool.t;
+val gt = _import "WordS8_gt" : Int8.t * Int8.t -> Bool.t;
+val le = _import "WordS8_le" : Int8.t * Int8.t -> Bool.t;
+val lt = _import "WordS8_lt" : Int8.t * Int8.t -> Bool.t;
+val mul = _import "WordS8_mul" : Int8.t * Int8.t -> Int8.t;
+val mulCheckOverflows = _import "WordS8_mulCheckOverflows" : Int8.t * Int8.t -> Bool.t;
+val negCheckOverflows = _import "WordS8_negCheckOverflows" : Int8.t -> Bool.t;
+val quot = _import "WordS8_quot" : Int8.t * Int8.t -> Int8.t;
+val rem = _import "WordS8_rem" : Int8.t * Int8.t -> Int8.t;
+val rshift = _import "WordS8_rshift" : Int8.t * Word32.t -> Int8.t;
+val subCheckOverflows = _import "WordS8_subCheckOverflows" : Int8.t * Int8.t -> Bool.t;
+val toReal32 = _import "WordS8_toReal32" : Int8.t -> Real32.t;
+val toReal64 = _import "WordS8_toReal64" : Int8.t -> Real64.t;
+val toWord16 = _import "WordS8_toWord16" : Int8.t -> Word16.t;
+val toWord32 = _import "WordS8_toWord32" : Int8.t -> Word32.t;
+val toWord64 = _import "WordS8_toWord64" : Int8.t -> Word64.t;
+val toWord8 = _import "WordS8_toWord8" : Int8.t -> Word8.t;
+end
+structure WordU16 =
+struct
+val addCheckOverflows = _import "WordU16_addCheckOverflows" : Word16.t * Word16.t -> Bool.t;
+val ge = _import "WordU16_ge" : Word16.t * Word16.t -> Bool.t;
+val gt = _import "WordU16_gt" : Word16.t * Word16.t -> Bool.t;
+val le = _import "WordU16_le" : Word16.t * Word16.t -> Bool.t;
+val lt = _import "WordU16_lt" : Word16.t * Word16.t -> Bool.t;
+val mul = _import "WordU16_mul" : Word16.t * Word16.t -> Word16.t;
+val mulCheckOverflows = _import "WordU16_mulCheckOverflows" : Word16.t * Word16.t -> Bool.t;
+val quot = _import "WordU16_quot" : Word16.t * Word16.t -> Word16.t;
+val rem = _import "WordU16_rem" : Word16.t * Word16.t -> Word16.t;
+val rshift = _import "WordU16_rshift" : Word16.t * Word32.t -> Word16.t;
+val toReal32 = _import "WordU16_toReal32" : Word16.t -> Real32.t;
+val toReal64 = _import "WordU16_toReal64" : Word16.t -> Real64.t;
+val toWord16 = _import "WordU16_toWord16" : Word16.t -> Word16.t;
+val toWord32 = _import "WordU16_toWord32" : Word16.t -> Word32.t;
+val toWord64 = _import "WordU16_toWord64" : Word16.t -> Word64.t;
+val toWord8 = _import "WordU16_toWord8" : Word16.t -> Word8.t;
+end
+structure WordU32 =
+struct
+val addCheckOverflows = _import "WordU32_addCheckOverflows" : Word32.t * Word32.t -> Bool.t;
+val ge = _import "WordU32_ge" : Word32.t * Word32.t -> Bool.t;
+val gt = _import "WordU32_gt" : Word32.t * Word32.t -> Bool.t;
+val le = _import "WordU32_le" : Word32.t * Word32.t -> Bool.t;
+val lt = _import "WordU32_lt" : Word32.t * Word32.t -> Bool.t;
+val mul = _import "WordU32_mul" : Word32.t * Word32.t -> Word32.t;
+val mulCheckOverflows = _import "WordU32_mulCheckOverflows" : Word32.t * Word32.t -> Bool.t;
+val quot = _import "WordU32_quot" : Word32.t * Word32.t -> Word32.t;
+val rem = _import "WordU32_rem" : Word32.t * Word32.t -> Word32.t;
+val rshift = _import "WordU32_rshift" : Word32.t * Word32.t -> Word32.t;
+val toReal32 = _import "WordU32_toReal32" : Word32.t -> Real32.t;
+val toReal64 = _import "WordU32_toReal64" : Word32.t -> Real64.t;
+val toWord16 = _import "WordU32_toWord16" : Word32.t -> Word16.t;
+val toWord32 = _import "WordU32_toWord32" : Word32.t -> Word32.t;
+val toWord64 = _import "WordU32_toWord64" : Word32.t -> Word64.t;
+val toWord8 = _import "WordU32_toWord8" : Word32.t -> Word8.t;
+end
+structure WordU64 =
+struct
+val addCheckOverflows = _import "WordU64_addCheckOverflows" : Word64.t * Word64.t -> Bool.t;
+val ge = _import "WordU64_ge" : Word64.t * Word64.t -> Bool.t;
+val gt = _import "WordU64_gt" : Word64.t * Word64.t -> Bool.t;
+val le = _import "WordU64_le" : Word64.t * Word64.t -> Bool.t;
+val lt = _import "WordU64_lt" : Word64.t * Word64.t -> Bool.t;
+val mul = _import "WordU64_mul" : Word64.t * Word64.t -> Word64.t;
+val mulCheckOverflows = _import "WordU64_mulCheckOverflows" : Word64.t * Word64.t -> Bool.t;
+val quot = _import "WordU64_quot" : Word64.t * Word64.t -> Word64.t;
+val rem = _import "WordU64_rem" : Word64.t * Word64.t -> Word64.t;
+val rshift = _import "WordU64_rshift" : Word64.t * Word32.t -> Word64.t;
+val toReal32 = _import "WordU64_toReal32" : Word64.t -> Real32.t;
+val toReal64 = _import "WordU64_toReal64" : Word64.t -> Real64.t;
+val toWord16 = _import "WordU64_toWord16" : Word64.t -> Word16.t;
+val toWord32 = _import "WordU64_toWord32" : Word64.t -> Word32.t;
+val toWord64 = _import "WordU64_toWord64" : Word64.t -> Word64.t;
+val toWord8 = _import "WordU64_toWord8" : Word64.t -> Word8.t;
+end
+structure WordU8 =
+struct
+val addCheckOverflows = _import "WordU8_addCheckOverflows" : Word8.t * Word8.t -> Bool.t;
+val ge = _import "WordU8_ge" : Word8.t * Word8.t -> Bool.t;
+val gt = _import "WordU8_gt" : Word8.t * Word8.t -> Bool.t;
+val le = _import "WordU8_le" : Word8.t * Word8.t -> Bool.t;
+val lt = _import "WordU8_lt" : Word8.t * Word8.t -> Bool.t;
+val mul = _import "WordU8_mul" : Word8.t * Word8.t -> Word8.t;
+val mulCheckOverflows = _import "WordU8_mulCheckOverflows" : Word8.t * Word8.t -> Bool.t;
+val quot = _import "WordU8_quot" : Word8.t * Word8.t -> Word8.t;
+val rem = _import "WordU8_rem" : Word8.t * Word8.t -> Word8.t;
+val rshift = _import "WordU8_rshift" : Word8.t * Word32.t -> Word8.t;
+val toReal32 = _import "WordU8_toReal32" : Word8.t -> Real32.t;
+val toReal64 = _import "WordU8_toReal64" : Word8.t -> Real64.t;
+val toWord16 = _import "WordU8_toWord16" : Word8.t -> Word16.t;
+val toWord32 = _import "WordU8_toWord32" : Word8.t -> Word32.t;
+val toWord64 = _import "WordU8_toWord64" : Word8.t -> Word64.t;
+val toWord8 = _import "WordU8_toWord8" : Word8.t -> Word8.t;
+end
+end
+end
Modified: mlton/branches/on-20050822-x86_64-branch/basis-library/primitive/check-real.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library/primitive/check-real.sml 2006-05-21 23:07:23 UTC (rev 4563)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/primitive/check-real.sml 2006-05-22 15:56:43 UTC (rev 4564)
@@ -32,18 +32,28 @@
val () = check (R1.Math.tanh, R2.Math.tanh)
val () = check (R1.abs, R2.abs)
+ val () = check (R1.+, R2.add)
val () = check (R1.class, R2.class)
+ val () = check (R1./, R2.div)
+ val () = check (R1.==, R2.equal)
val () = check (R1.frexp, R2.frexp)
val () = check (R1.gdtoa, R2.gdtoa)
val () = check (R1.ldexp, R2.ldexp)
+ val () = check (R1.<=, R2.le)
+ val () = check (R1.<, R2.lt)
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.*, R2.mul)
+ val () = check (R1.*+, R2.muladd)
+ val () = check (R1.*-, R2.mulsub)
+ val () = check (R1.~, R2.neg)
val () = check (R1.nextAfter, R2.nextAfter)
val () = check (R1.round, R2.round)
val () = check (R1.signBit, R2.signBit)
val () = check (R1.strto, R2.strto)
+ val () = check (R1.-, R2.sub)
end
local
@@ -69,18 +79,28 @@
val () = check (R1.Math.tanh, R2.Math.tanh)
val () = check (R1.abs, R2.abs)
+ val () = check (R1.+, R2.add)
val () = check (R1.class, R2.class)
+ val () = check (R1./, R2.div)
+ val () = check (R1.==, R2.equal)
val () = check (R1.frexp, R2.frexp)
val () = check (R1.gdtoa, R2.gdtoa)
val () = check (R1.ldexp, R2.ldexp)
+ val () = check (R1.<=, R2.le)
+ val () = check (R1.<, R2.lt)
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.*, R2.mul)
+ val () = check (R1.*+, R2.muladd)
+ val () = check (R1.*-, R2.mulsub)
+ val () = check (R1.~, R2.neg)
val () = check (R1.nextAfter, R2.nextAfter)
val () = check (R1.round, R2.round)
val () = check (R1.signBit, R2.signBit)
val () = check (R1.strto, R2.strto)
+ val () = check (R1.-, R2.sub)
end
in
Modified: mlton/branches/on-20050822-x86_64-branch/bytecode/interpret.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/bytecode/interpret.c 2006-05-21 23:07:23 UTC (rev 4563)
+++ mlton/branches/on-20050822-x86_64-branch/bytecode/interpret.c 2006-05-22 15:56:43 UTC (rev 4564)
@@ -6,7 +6,7 @@
*/
#define MLTON_GC_INTERNAL_TYPES
-#define MLTON_BASIS_FFI_STATIC
+#define MLTON_CODEGEN_STATIC_INLINE static inline
#include "platform.h"
#include "interpret.h"
@@ -61,18 +61,6 @@
#define R(ty, i) (ty##VReg [i])
-#define quotRem1(qr, size) \
- Word##size WordS##size##_##qr (Word##size w1, Word##size w2);
-#define quotRem2(qr) \
- quotRem1 (qr, 8) \
- quotRem1 (qr, 16) \
- quotRem1 (qr, 32) \
- quotRem1 (qr, 64)
-quotRem2 (quot)
-quotRem2 (rem)
-#undef quotRem1
-#undef quotRem2
-
//----------------------------------------------------------------------
#define Fetch(t, z) \
Modified: mlton/branches/on-20050822-x86_64-branch/include/bytecode-main.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/include/bytecode-main.h 2006-05-21 23:07:23 UTC (rev 4563)
+++ mlton/branches/on-20050822-x86_64-branch/include/bytecode-main.h 2006-05-22 15:56:43 UTC (rev 4564)
@@ -30,20 +30,20 @@
fprintf (stderr, "MLton_callFromC() starting\n"); \
s = &gcState; \
s->savedThread = s->currentThread; \
- s->canHandle += 3; \
+ s->atomicState += 3; \
/* Switch to the C Handler thread. */ \
- GC_switchToThread (s, s->callFromCHandler, 0); \
+ GC_switchToThread (s, s->callFromCHandlerThread, 0); \
nextFun = *(int*)(s->stackTop - GC_RETURNADDRESS_SIZE); \
MLton_Bytecode_interpret (&MLton_bytecode, nextFun); \
GC_switchToThread (s, s->savedThread, 0); \
- s->savedThread = BOGUS_THREAD; \
+ s->savedThread = BOGUS_OBJPTR; \
if (DEBUG_CODEGEN) \
fprintf (stderr, "MLton_callFromC done\n"); \
} \
int main (int argc, char **argv) { \
int nextFun; \
Initialize (al, mg, mfs, mmc, pk, ps); \
- if (gcState.isOriginal) { \
+ if (gcState.amOriginal) { \
real_Init(); \
nextFun = ml; \
} else { \
Modified: mlton/branches/on-20050822-x86_64-branch/include/c-chunk.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/include/c-chunk.h 2006-05-21 23:07:23 UTC (rev 4563)
+++ mlton/branches/on-20050822-x86_64-branch/include/c-chunk.h 2006-05-22 15:56:43 UTC (rev 4564)
@@ -11,9 +11,9 @@
#include <stdio.h>
-#include "assert.h"
-#include "c-common.h"
#include "ml-types.h"
+#include "c-types.h"
+#include "c-common.h"
#ifndef TRUE
#define TRUE 1
@@ -169,7 +169,6 @@
fprintf (stderr, "%s:%d: Push (%d)\n", \
__FILE__, __LINE__, bytes); \
StackTop += (bytes); \
- assert (StackBottom <= StackTop); \
} while (0)
#define Return() \
@@ -191,91 +190,24 @@
} while (0) \
/* ------------------------------------------------- */
-/* Real */
+/* Primitives */
/* ------------------------------------------------- */
-#define unaryReal(f, g) \
- Real64 g (Real64 x); \
- static inline Real64 Real64_##f (Real64 x) { \
- return g (x); \
- } \
- static inline Real32 Real32_##f (Real32 x) { \
- return (Real32)(Real64_##f ((Real64)x)); \
- }
-unaryReal(round, rint)
-#undef unaryReal
+#ifndef MLTON_CODEGEN_STATIC_INLINE
+#define MLTON_CODEGEN_STATIC_INLINE static inline
+#endif
+#define MLTON_CCODEGEN_HIDE(z)
+#include "basis/coerce.h"
+#include "basis/Real/Real-ops.h"
+#include "basis/Real/Math-fns.h"
+#include "basis/Word/Word-ops.h"
+#include "basis/Word/Word-consts.h"
+#include "basis/Word/Word-check.h"
-#define binaryReal(f, g) \
- Real64 g (Real64 x, Real64 y); \
- static inline Real64 Real64_Math_##f (Real64 x, Real64 y) { \
- return g (x, y); \
- } \
- static inline Real32 Real32_Math_##f (Real32 x, Real32 y) { \
- return (Real32)(Real64_Math_##f ((Real64)x, (Real64)y)); \
- }
-binaryReal(atan2, atan2)
-#undef binaryReal
+/* ------------------------------------------------- */
+/* Real */
+/* ------------------------------------------------- */
-#define unaryReal(f, g) \
- Real64 g (Real64 x); \
- static inline Real64 Real64_Math_##f (Real64 x) { \
- return g (x); \
- } \
- static inline Real32 Real32_Math_##f (Real32 x) { \
- return (Real32)(Real64_Math_##f ((Real64)x)); \
- }
-unaryReal(acos, acos)
-unaryReal(asin, asin)
-unaryReal(atan, atan)
-unaryReal(cos, cos)
-unaryReal(exp, exp)
-unaryReal(ln, log)
-unaryReal(log10, log10)
-unaryReal(sin, sin)
-unaryReal(sqrt, sqrt)
-unaryReal(tan, tan)
-#undef unaryReal
-
-double ldexp (double x, int i);
-static inline Real64 Real64_ldexp (Real64 x, Int32 i) {
- return ldexp (x, i);
-}
-static inline Real32 Real32_ldexp (Real32 x, Int32 i) {
- return (Real32)Real64_ldexp ((Real64)x, i);
-}
-
-#define binaryReal(name, op) \
- static inline Real32 Real32_##name (Real32 x, Real32 y) { \
- return x op y; \
- } \
- static inline Real64 Real64_##name (Real64 x, Real64 y) { \
- return x op y; \
- }
-binaryReal(add, +)
-binaryReal(div, /)
-binaryReal(mul, *)
-binaryReal(sub, -)
-#undef binaryReal
-
-#define binaryReal(name, op) \
- static inline Bool Real32_##name (Real32 x, Real32 y) { \
- return x op y; \
- } \
- static inline Bool Real64_##name (Real64 x, Real64 y) { \
- return x op y; \
- }
-binaryReal(equal, ==)
-binaryReal(le, <=)
-binaryReal(lt, <)
-#undef binaryReal
-
-#define Real32_muladd(x, y, z) ((x) * (y) + (z))
-#define Real32_mulsub(x, y, z) ((x) * (y) - (z))
-#define Real64_muladd(x, y, z) ((x) * (y) + (z))
-#define Real64_mulsub(x, y, z) ((x) * (y) - (z))
-#define Real32_neg(x) (-(x))
-#define Real64_neg(x) (-(x))
-
typedef volatile union {
Word32 tab[2];
Real64 d;
@@ -317,255 +249,109 @@
/* Word */
/* ------------------------------------------------- */
-#define wordBinary(size, name, op) \
- static inline Word##size Word##size##_##name \
- (Word##size w1, Word##size w2) { \
- return w1 op w2; \
- }
-#define wordCmp(size, name, op) \
- static inline Bool Word##size##_##name \
- (Word##size w1, Word##size w2) { \
- Bool res = w1 op w2; \
- if (DEBUG_CCODEGEN) \
- fprintf (stderr, "%s = 0x%08x " #op " 0x%08x\n", \
- res ? "true": "false", \
- (unsigned int)w1, \
- (unsigned int)w2); \
- return w1 op w2; \
- }
-#define wordShift(size, name, op) \
- static inline Word##size Word##size##_##name \
- (Word##size w1, Word32 w2) { \
- return w1 op w2; \
- }
-#define wordUnary(size, name, op) \
- static inline Word##size Word##size##_##name (Word##size w) { \
- return op w; \
- }
-#define wordOps(size) \
- wordBinary (size, add, +) \
- wordBinary (size, andb, &) \
- wordBinary (S##size, mul, *) \
- wordBinary (U##size, mul, *) \
- wordBinary (size, orb, |) \
- wordBinary (U##size, quot, /) \
- wordBinary (U##size, rem, %) \
- wordBinary (size, sub, -) \
- wordBinary (size, xorb, ^) \
- wordCmp (size, equal, ==) \
- wordCmp (S##size, lt, <) \
- wordCmp (U##size, lt, <) \
- wordShift (size, lshift, <<) \
- wordShift (U##size, rshift, >>) \
- wordUnary (size, neg, -) \
- wordUnary (size, notb, ~) \
- /* WordS_rshift isn't ANSI C, because ANSI doesn't guarantee sign \
- * extension. We use it anyway cause it always seems to work. \
- */ \
- static inline Word##size WordS##size##_rshift (WordS##size w, Word32 s) { \
- return w >> s; \
- } \
- static inline Word##size Word##size##_rol (Word##size w1, Word32 w2) { \
- return (w1 >> (size - w2)) | (w1 << w2); \
- } \
- static inline Word##size Word##size##_ror (Word##size w1, Word32 w2) { \
- return (w1 >> w2) | (w1 << (size - w2)); \
- }
-wordOps(8)
-wordOps(16)
-wordOps(32)
-wordOps(64)
-#undef wordBinary
-#undef wordCmp
-#undef wordOps
-#undef wordShift
-#undef wordUnary
+#define WordS_addCheckCX(size, dst, cW, xW, l) \
+ do { \
+ WordS##size c = cW; \
+ WordS##size x = xW; \
+ WordS_addCheckBodyCX(size, c, x, goto l, dst = c + x); \
+ } while (0)
+#define WordS8_addCheckCX(dst, c, x, l) WordS_addCheckCX(8, dst, c, x, l)
+#define WordS16_addCheckCX(dst, c, x, l) WordS_addCheckCX(16, dst, c, x, l)
+#define WordS32_addCheckCX(dst, c, x, l) WordS_addCheckCX(32, dst, c, x, l)
+#define WordS64_addCheckCX(dst, c, x, l) WordS_addCheckCX(64, dst, c, x, l)
-#define coerce(f, t) \
- static inline t f##_to##t (f x) { \
- return (t)x; \
- }
-coerce (Real32, Real64)
-coerce (Real32, WordS32)
-coerce (Real64, Real32)
-coerce (Real64, WordS32)
-coerce (WordS16, Real32)
-coerce (WordS16, Real64)
-coerce (WordS16, Word32)
-coerce (WordS16, Word64)
-coerce (WordS32, Real32)
-coerce (WordS32, Real64)
-coerce (WordS32, Word64)
-coerce (WordS8, Real32)
-coerce (WordS8, Real64)
-coerce (WordS8, Word16)
-coerce (WordS8, Word32)
-coerce (WordS8, Word64)
-coerce (WordU16, Word32)
-coerce (WordU16, Word64)
-coerce (WordU16, Word8)
-coerce (WordU32, Word16)
-coerce (WordU32, Word64)
-coerce (WordU32, Word8)
-coerce (WordU64, Word16)
-coerce (WordU64, Word32)
-coerce (WordU64, Word8)
-coerce (WordU8, Word16)
-coerce (WordU8, Word32)
-coerce (WordU8, Word64)
-#undef coerce
+#define WordS8_addCheckXC(dst, x, c, l) WordS8_addCheckCX(dst, c, x, l)
+#define WordS16_addCheckXC(dst, x, c, l) WordS16_addCheckCX(dst, c, x, l)
+#define WordS32_addCheckXC(dst, x, c, l) WordS32_addCheckCX(dst, c, x, l)
+#define WordS64_addCheckXC(dst, x, c, l) WordS64_addCheckCX(dst, c, x, l)
-#define WordS8_max (WordS8)0x7F
-#define WordS8_min (WordS8)0x80
-#define WordS16_max (WordS16)0x7FFF
-#define WordS16_min (WordS16)0x8000
-#define WordS32_max (WordS32)0x7FFFFFFF
-#define WordS32_min (WordS32)0x80000000
-#define WordS64_max (WordS64)0x7FFFFFFFFFFFFFFFll
-#define WordS64_min (WordS64)0x8000000000000000ll
-#define Word8_max (Word8)0xFF
-#define Word16_max (Word16)0xFFFF
-#define Word32_max (Word32)0xFFFFFFFF
-#define Word64_max (Word64)0xFFFFFFFFFFFFFFFFull
-
-#define WordS_addCheckXC(size, dst, xW, cW, l) \
- do { \
- WordS##size x = xW; \
- WordS##size c = cW; \
- dst = x + c; \
- if (c >= 0) { \
- if (x > WordS##size##_max - c) \
- goto l; \
- } else if (x < WordS##size##_min - c) \
- goto l; \
- } while (0)
-#define WordS8_addCheckXC(dst, x, c, l) WordS_addCheckXC(8, dst, x, c, l)
-#define WordS16_addCheckXC(dst, x, c, l) WordS_addCheckXC(16, dst, x, c, l)
-#define WordS32_addCheckXC(dst, x, c, l) WordS_addCheckXC(32, dst, x, c, l)
-#define WordS64_addCheckXC(dst, x, c, l) WordS_addCheckXC(64, dst, x, c, l)
-
-#define WordS8_addCheckCX(dst, c, x, l) WordS8_addCheckXC(dst, x, c, l)
-#define WordS16_addCheckCX(dst, c, x, l) WordS16_addCheckXC(dst, x, c, l)
-#define WordS32_addCheckCX(dst, c, x, l) WordS32_addCheckXC(dst, x, c, l)
-#define WordS64_addCheckCX(dst, c, x, l) WordS64_addCheckXC(dst, x, c, l)
-
-#define WordS8_addCheck(dst, x, y, l) WordS8_addCheckXC (dst, x, y, l)
+#define WordS8_addCheck WordS8_addCheckXC
#define WordS16_addCheck WordS16_addCheckXC
#define WordS32_addCheck WordS32_addCheckXC
#define WordS64_addCheck WordS64_addCheckXC
-#define WordS_negCheck(size, dst, nW, l) \
- do { \
- WordS##size n = nW; \
- dst = -n; \
- if (n == WordS##size##_min) \
- goto l; \
- } while (0)
-#define Word8_negCheck(dst, n, l) WordS_negCheck(8, dst, n, l)
-#define Word16_negCheck(dst, n, l) WordS_negCheck(16, dst, n, l)
-#define Word32_negCheck(dst, n, l) WordS_negCheck(32, dst, n, l)
-#define Word64_negCheck(dst, n, l) WordS_negCheck(64, dst, n, l)
+#define WordU_addCheckCX(size, dst, cW, xW, l) \
+ do { \
+ WordU##size c = cW; \
+ WordU##size x = xW; \
+ WordU_addCheckBodyCX(size, c, x, goto l, dst = c + x); \
+ } while (0)
+#define WordU8_addCheckCX(dst, c, x, l) WordU_addCheckCX(8, dst, c, x, l)
+#define WordU16_addCheckCX(dst, c, x, l) WordU_addCheckCX(16, dst, c, x, l)
+#define WordU32_addCheckCX(dst, c, x, l) WordU_addCheckCX(32, dst, c, x, l)
+#define WordU64_addCheckCX(dst, c, x, l) WordU_addCheckCX(64, dst, c, x, l)
-#define WordS_subCheckCX(size, dst, cW, xW, l) \
- do { \
- WordS##size c = cW; \
- WordS##size x = xW; \
- dst = c - x; \
- if (c >= 0) { \
- if (x < c - WordS##size##_max) \
- goto l; \
- } else if (x > c - WordS##size##_min) \
- goto l; \
- } while (0)
+#define WordU8_addCheckXC(dst, x, c, l) WordU8_addCheckCX(dst, c, x, l)
+#define WordU16_addCheckXC(dst, x, c, l) WordU16_addCheckCX(dst, c, x, l)
+#define WordU32_addCheckXC(dst, x, c, l) WordU32_addCheckCX(dst, c, x, l)
+#define WordU64_addCheckXC(dst, x, c, l) WordU64_addCheckCX(dst, c, x, l)
+
+#define WordU8_addCheck WordU8_addCheckXC
+#define WordU16_addCheck WordU16_addCheckXC
+#define WordU32_addCheck WordU32_addCheckXC
+#define WordU64_addCheck WordU64_addCheckXC
+
+
+#define WordS_negCheck(size, dst, xW, l) \
+ do { \
+ WordS##size x = xW; \
+ WordS_negCheckBody(size, x, goto l, dst = -x); \
+ } while (0)
+#define Word8_negCheck(dst, x, l) WordS_negCheck(8, dst, x, l)
+#define Word16_negCheck(dst, x, l) WordS_negCheck(16, dst, x, l)
+#define Word32_negCheck(dst, x, l) WordS_negCheck(32, dst, x, l)
+#define Word64_negCheck(dst, x, l) WordS_negCheck(64, dst, x, l)
+
+
+#define WordS_subCheckCX(size, dst, cW, xW, l) \
+ do { \
+ WordS##size c = cW; \
+ WordS##size x = xW; \
+ WordS_subCheckBodyCX(size, c, x, goto l, dst = c - x); \
+ } while (0)
#define WordS8_subCheckCX(dst, c, x, l) WordS_subCheckCX(8, dst, c, x, l)
#define WordS16_subCheckCX(dst, c, x, l) WordS_subCheckCX(16, dst, c, x, l)
#define WordS32_subCheckCX(dst, c, x, l) WordS_subCheckCX(32, dst, c, x, l)
#define WordS64_subCheckCX(dst, c, x, l) WordS_subCheckCX(64, dst, c, x, l)
-#define WordS_subCheckXC(size, dst, xW, cW, l) \
- do { \
- WordS##size c = cW; \
- WordS##size x = xW; \
- if (c <= 0) { \
- if (x > WordS##size##_max + c) \
- goto l; \
- } else if (x < WordS##size##_min + c) \
- goto l; \
- dst = x - c; \
- } while (0)
-#define WordS8_subCheckXC(dst, c, x, l) WordS_subCheckXC(8, dst, c, x, l)
-#define WordS16_subCheckXC(dst, c, x, l) WordS_subCheckXC(16, dst, c, x, l)
-#define WordS32_subCheckXC(dst, c, x, l) WordS_subCheckXC(32, dst, c, x, l)
-#define WordS64_subCheckXC(dst, c, x, l) WordS_subCheckXC(64, dst, c, x, l)
+#define WordS_subCheckXC(size, dst, xW, cW, l) \
+ do { \
+ WordS##size x = xW; \
+ WordS##size c = cW; \
+ WordS_subCheckBodyXC(size, x, c, goto l, dst = x - c); \
+ } while (0)
+#define WordS8_subCheckXC(dst, x, c, l) WordS_subCheckXC(8, dst, x, c, l)
+#define WordS16_subCheckXC(dst, x, c, l) WordS_subCheckXC(16, dst, x, c, l)
+#define WordS32_subCheckXC(dst, x, c, l) WordS_subCheckXC(32, dst, x, c, l)
+#define WordS64_subCheckXC(dst, x, c, l) WordS_subCheckXC(64, dst, x, c, l)
#define WordS8_subCheck WordS8_subCheckXC
#define WordS16_subCheck WordS16_subCheckXC
#define WordS32_subCheck WordS32_subCheckXC
#define WordS64_subCheck WordS64_subCheckXC
-#define WordU_addCheckXC(size, dst, x, c, l) \
- do { \
- dst = x + c; \
- if (x > Word##size##_max - c) \
- goto l; \
- } while (0)
-#define WordU8_addCheckXC(dst, x, c, l) WordU_addCheckXC(8, dst, x, c, l)
-#define WordU16_addCheckXC(dst, x, c, l) WordU_addCheckXC(16, dst, x, c, l)
-#define WordU32_addCheckXC(dst, x, c, l) WordU_addCheckXC(32, dst, x, c, l)
-#define WordU64_addCheckXC(dst, x, c, l) WordU_addCheckXC(64, dst, x, c, l)
-#define WordU8_addCheckCX(dst, c, x, l) WordU_addCheckXC(8, dst, x, c, l)
-#define WordU16_addCheckCX(dst, c, x, l) WordU_addCheckXC(16, dst, x, c, l)
-#define WordU32_addCheckCX(dst, c, x, l) WordU_addCheckXC(32, dst, x, c, l)
-#define WordU64_addCheckCX(dst, c, x, l) WordU_addCheckXC(64, dst, x, c, l)
-#define WordU8_addCheck WordU8_addCheckXC
-#define WordU16_addCheck WordU16_addCheckXC
-#define WordU32_addCheck WordU32_addCheckXC
-#define WordU64_addCheck WordU64_addCheckXC
+#define WordS_mulCheck(size, dst, xW, yW, l) \
+ do { \
+ WordS##size x = xW; \
+ WordS##size y = yW; \
+ WordS_mulCheckBody(size, x, y, goto l, dst = x * y); \
+ } while (0)
+#define WordS8_mulCheck(dst, x, y, l) WordS_mulCheck(8, dst, x, y, l)
+#define WordS16_mulCheck(dst, x, y, l) WordS_mulCheck(16, dst, x, y, l)
+#define WordS32_mulCheck(dst, x, y, l) WordS_mulCheck(32, dst, x, y, l)
+#define WordS64_mulCheck(dst, x, y, l) WordS_mulCheck(64, dst, x, y, l)
-#define mulOverflow(small, large) \
- static inline Word##small Word##small##_##mulOverflow \
- (Word##small x1, Word##small x2, Bool *overflow) { \
- Word##large tmp; \
- Word##small res; \
- \
- tmp = (Word##large)x1 * x2; \
- res = tmp; \
- *overflow = (tmp != res); \
- return res; \
- }
-mulOverflow(S8, S16)
-mulOverflow(S16, S32)
-mulOverflow(S32, S64)
-mulOverflow(U8, U16)
-mulOverflow(U16, U32)
-mulOverflow(U32, U64)
-#undef mulOverflow
+#define WordU_mulCheck(size, dst, xW, yW, l) \
+ do { \
+ WordU##size x = xW; \
+ WordU##size y = yW; \
+ WordU_mulCheckBody(size, x, y, goto l, dst = x * y); \
+ } while (0)
+#define WordU8_mulCheck(dst, x, y, l) WordU_mulCheck(8, dst, x, y, l)
+#define WordU16_mulCheck(dst, x, y, l) WordU_mulCheck(16, dst, x, y, l)
+#define WordU32_mulCheck(dst, x, y, l) WordU_mulCheck(32, dst, x, y, l)
+#define WordU64_mulCheck(dst, x, y, l) WordU_mulCheck(64, dst, x, y, l)
-#define check(dst, n1, n2, l, ty); \
- do { \
- Bool overflow; \
- ty tmp; \
- tmp = ty##_mulOverflow (n1, n2, &overflow); \
- if (DEBUG_CCODEGEN) \
- fprintf (stderr, "%s:%d: " #ty "_mulOverflow (%d, %d) = %d\n", \
- __FILE__, __LINE__, \
- (int)n1, (int)n2, (int)tmp); \
- if (overflow) { \
- if (DEBUG_CCODEGEN) \
- fprintf (stderr, "%s:%d: overflow\n", \
- __FILE__, __LINE__); \
- goto l; \
- } \
- dst = tmp; \
- } while (0)
-
-#define WordS8_mulCheck(dst, n1, n2, l) check (dst, n1, n2, l, WordS8)
-#define WordS16_mulCheck(dst, n1, n2, l) check (dst, n1, n2, l, WordS16)
-#define WordS32_mulCheck(dst, n1, n2, l) check (dst, n1, n2, l, WordS32)
-#define WordU8_mulCheck(dst, n1, n2, l) check (dst, n1, n2, l, WordU8)
-#define WordU16_mulCheck(dst, n1, n2, l) check (dst, n1, n2, l, WordU16)
-#define WordU32_mulCheck(dst, n1, n2, l) check (dst, n1, n2, l, WordU32)
-
#endif /* #ifndef _C_CHUNK_H_ */
Modified: mlton/branches/on-20050822-x86_64-branch/runtime/Makefile
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/Makefile 2006-05-21 23:07:23 UTC (rev 4563)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/Makefile 2006-05-22 15:56:43 UTC (rev 4564)
@@ -138,10 +138,12 @@
GCHFILES = \
$(shell find gc -type f | grep '\.h$$')
+BASISHFILES = \
+ $(shell find basis -type f | grep '\.h$$')
+
CFILES = \
$(UTILCFILES) \
$(shell find basis -type f | grep '\.c$$' | grep -v Real/) \
- $(shell find Posix -type f | grep '\.c$$') \
gc.c \
platform.c
@@ -154,7 +156,8 @@
c-types.h \
basis-ffi.h \
platform.h \
- platform/$(TARGET_OS).h
+ platform/$(TARGET_OS).h \
+ $(BASISHFILES)
FILES = $(basename $(CFILES))
@@ -255,9 +258,9 @@
# with -fno-strict-aliasing to prevent gcc from taking advantage of
# this aspect of the C spec.
basis/Real/%-gdb.o: basis/Real/%.c gdtoa/arith.h $(HFILES)
- $(CC) $(DEBUGCFLAGS) $(DEBUGWARNCFLAGS) -c -o $@ $<
+ $(CC) $(DEBUGCFLAGS) $(DEBUGWARNCFLAGS) -Wno-float-equal -c -o $@ $<
basis/Real/%.o: basis/Real/%.c gdtoa/arith.h $(HFILES)
- $(CC) $(OPTCFLAGS) $(OPTWARNCFLAGS) -O1 -fno-strict-aliasing -c -o $@ $<
+ $(CC) $(OPTCFLAGS) $(OPTWARNCFLAGS) -Wno-float-equal -O1 -fno-strict-aliasing -c -o $@ $<
%-gdb.o: %.c $(HFILES)
$(CC) $(DEBUGCFLAGS) $(DEBUGWARNCFLAGS) -c -o $@ $<
Added: mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/Math-fns.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/Math-fns.h 2006-05-21 23:07:23 UTC (rev 4563)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/Math-fns.h 2006-05-22 15:56:43 UTC (rev 4564)
@@ -0,0 +1,74 @@
+
+#define unaryReal(g, h) \
+ MLTON_CODEGEN_STATIC_INLINE \
+ Real64_t Real64_##g (Real64_t x) { \
+ return h (x); \
+ } \
+ MLTON_CODEGEN_STATIC_INLINE \
+ Real32_t Real32_##g (Real32_t x) { \
+ return h##f (x); \
+ }
+unaryReal(abs, fabs)
+unaryReal(round, rint)
+#undef unaryReal
+
+#define binaryReal(g, h) \
+ MLTON_CODEGEN_STATIC_INLINE \
+ Real64_t Real64_Math_##g (Real64_t x, Real64_t y) { \
+ return h (x, y); \
+ } \
+ MLTON_CODEGEN_STATIC_INLINE \
+ Real32_t Real32_Math_##g (Real32_t x, Real32_t y) { \
+ return h##f (x, y); \
+ }
+binaryReal(atan2, atan2)
+binaryReal(pow, pow)
+#undef binaryReal
+
+#define unaryReal(g, h) \
+ MLTON_CODEGEN_STATIC_INLINE \
+ Real64_t Real64_Math_##g (Real64_t x) { \
+ return h (x); \
+ } \
+ MLTON_CODEGEN_STATIC_INLINE \
+ Real32_t Real32_Math_##g (Real32_t x) { \
+ return h##f (x); \
+ }
+unaryReal(acos, acos)
+unaryReal(asin, asin)
+unaryReal(atan, atan)
+unaryReal(cos, cos)
+unaryReal(cosh, cosh)
+unaryReal(exp, exp)
+unaryReal(ln, log)
+unaryReal(log10, log10)
+unaryReal(sin, sin)
+unaryReal(sinh, sinh)
+unaryReal(sqrt, sqrt)
+unaryReal(tan, tan)
+unaryReal(tanh, tanh)
+#undef unaryReal
+
+#define binaryRealIntRef(g, h) \
+ MLTON_CODEGEN_STATIC_INLINE \
+ Real64_t Real64_##g (Real64_t x, Ref(C_Int_t) i) { \
+ return h (x, (int*)i); \
+ } \
+ MLTON_CODEGEN_STATIC_INLINE \
+ Real32_t Real32_##g (Real32_t x, Ref(C_Int_t) i) { \
+ return h##f (x, (int*)i); \
+ }
+binaryRealIntRef(frexp, frexp)
+#undef binaryRealIntRef
+
+#define binaryRealInt(g, h) \
+ MLTON_CODEGEN_STATIC_INLINE \
+ Real64_t Real64_##g (Real64_t x, C_Int_t i) { \
+ return h (x, i); \
+ } \
+ MLTON_CODEGEN_STATIC_INLINE \
+ Real32_t Real32_##g (Real32_t x, C_Int_t i) { \
+ return h##f (x, i); \
+ }
+binaryRealInt(ldexp, ldexp)
+#undef binaryRealInt
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-05-21 23:07:23 UTC (rev 4563)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/Math.c 2006-05-22 15:56:43 UTC (rev 4564)
@@ -1,55 +1,3 @@
#include "platform.h"
-#define unaryReal(g, h) \
-Real64_t Real64_##g (Real64_t x) { \
- return h (x); \
-} \
-Real32_t Real32_##g (Real32_t x) { \
- return h##f (x); \
-}
-unaryReal(abs, fabs)
-unaryReal(round, rint)
-#undef unaryReal
-
-#define binaryReal(g, h) \
-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) { \
- return h##f (x, y); \
-}
-binaryReal(atan2, atan2)
-binaryReal(pow, pow)
-#undef binaryReal
-
-#define unaryReal(g, h) \
-Real64_t Real64_Math_##g (Real64_t x) { \
- return h (x); \
-} \
-Real32_t Real32_Math_##g (Real32_t x) { \
- return h##f (x); \
-}
-unaryReal(acos, acos)
-unaryReal(asin, asin)
-unaryReal(atan, atan)
-unaryReal(cos, cos)
-unaryReal(cosh, cosh)
-unaryReal(exp, exp)
-unaryReal(ln, log)
-unaryReal(log10, log10)
-unaryReal(sin, sin)
-unaryReal(sinh, sinh)
-unaryReal(sqrt, sqrt)
-unaryReal(tan, tan)
-unaryReal(tanh, tanh)
-#undef unaryReal
-
-#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); \
-}
-binaryRealInt(ldexp, ldexp)
-#undef binaryRealInt
+#include "Math-fns.h"
Added: mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/Real-consts.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/Real-consts.c 2006-05-21 23:07:23 UTC (rev 4563)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/Real-consts.c 2006-05-22 15:56:43 UTC (rev 4564)
@@ -0,0 +1,15 @@
+#include "platform.h"
+
+Real32_t Real32_Math_pi = (Real32_t)3.14159265358979323846;
+Real32_t Real32_Math_e = (Real32_t)2.71828182845904523536;
+
+Real32_t Real32_maxFinite = 3.40282347e+38;
+Real32_t Real32_minNormalPos = 1.17549435e-38;
+Real32_t Real32_minPos = 1.40129846e-45;
+
+Real64_t Real64_Math_pi = 3.14159265358979323846;
+Real64_t Real64_Math_e = 2.71828182845904523536;
+
+Real64_t Real64_maxFinite = 1.7976931348623157e+308;
+Real64_t Real64_minNormalPos = 2.2250738585072014e-308;
+Real64_t Real64_minPos = 4.9406564584124654e-324;
Added: mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/Real-ops.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/Real-ops.h 2006-05-21 23:07:23 UTC (rev 4563)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/Real-ops.h 2006-05-22 15:56:43 UTC (rev 4564)
@@ -0,0 +1,45 @@
+
+#define binary(size, name, op) \
+ MLTON_CODEGEN_STATIC_INLINE \
+ Real##size##_t Real##size##_##name (Real##size##_t r1, Real##size##_t r2) { \
+ return r1 op r2; \
+ }
+
+#define compare(size, name, op) \
+ MLTON_CODEGEN_STATIC_INLINE \
+ Bool Real##size##_##name (Real##size##_t r1, Real##size##_t r2) { \
+ return r1 op r2; \
+ }
+
+#define ternary(size, name, op) \
+ MLTON_CODEGEN_STATIC_INLINE \
+ Real##size##_t Real##size##_mul##name (Real##size##_t r1, Real##size##_t r2, Real##size##_t r3) { \
+ return r1 * r2 op r3; \
+ }
+
+#define unary(size, name, op) \
+ MLTON_CODEGEN_STATIC_INLINE \
+ Real##size##_t Real##size##_##name (Real##size##_t r1) { \
+ return op r1; \
+ }
+
+#define all(size) \
+binary(size, add, +) \
+binary(size, div, /) \
+binary(size, mul, *) \
+binary(size, sub, -) \
+compare(size, equal, ==) \
+compare(size, le, <=) \
+compare(size, lt, <) \
+ternary(size, add, +) \
+ternary(size, sub, -) \
+unary(size, neg, -)
+
+all(32)
+all(64)
+
+#undef all
+#undef unary
+#undef ternary
+#undef compare
+#undef binary
Modified: mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/Real.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/Real.c 2006-05-21 23:07:23 UTC (rev 4563)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/Real.c 2006-05-22 15:56:43 UTC (rev 4564)
@@ -1,28 +1,3 @@
#include "platform.h"
-Real32_t Real32_Math_pi = (Real32_t)3.14159265358979323846;
-Real32_t Real32_Math_e = (Real32_t)2.7182818284590452354;
-
-Real32_t Real32_maxFinite = 3.40282347e+38;
-Real32_t Real32_minNormalPos = 1.17549435e-38;
-Real32_t Real32_minPos = 1.40129846e-45;
-
-Real64_t Real64_Math_pi = 3.14159265358979323846;
-Real64_t Real64_Math_e = 2.7182818284590452354;
-
-Real64_t Real64_maxFinite = 1.7976931348623157e+308;
-Real64_t Real64_minNormalPos = 2.2250738585072014e-308;
-Real64_t Real64_minPos = 4.9406564584124654e-324;
-
-#define ternary(size, name, op) \
- Real##size##_t Real##size##_mul##name \
- (Real##size##_t r1, Real##size##_t r2, Real##size##_t r3); \
- Real##size##_t Real##size##_mul##name \
- (Real##size##_t r1, Real##size##_t r2, Real##size##_t r3) { \
- return r1 * r2 op r3; \
- }
-ternary(32, add, +)
-ternary(64, add, +)
-ternary(32, sub, -)
-ternary(64, sub, -)
-#undef ternary
+#include "Real-ops.h"
Deleted: 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-05-21 23:07:23 UTC (rev 4563)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/frexp.c 2006-05-22 15:56:43 UTC (rev 4564)
@@ -1,11 +0,0 @@
-#include "platform.h"
-
-#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); \
-}
-binaryRealIntRef(frexp, frexp)
-#undef binaryRealIntRef
Added: mlton/branches/on-20050822-x86_64-branch/runtime/basis/Word/Word-check.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/basis/Word/Word-check.h 2006-05-21 23:07:23 UTC (rev 4563)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/Word/Word-check.h 2006-05-22 15:56:43 UTC (rev 4564)
@@ -0,0 +1,168 @@
+
+#define WordS_addCheckBody(size, x, y, doOverflow, doSuccess) \
+ do { \
+ if (x >= 0) { \
+ if (y > WordS##size##_max - x) { \
+ doOverflow; \
+ } \
+ } else if (y < WordS##size##_min - x) { \
+ doOverflow; \
+ } \
+ doSuccess; \
+ } while (0)
+#define WordS_addCheckBodyCX(size, c, x, doOverflow, doSuccess) \
+WordS_addCheckBody(size, c, x, doOverflow, doSuccess)
+
+#define WordU_addCheckBody(size, x, y, doOverflow, doSuccess) \
+ do { \
+ if (y > Word##size##_max - x) { \
+ doOverflow; \
+ } \
+ doSuccess; \
+ } while (0)
+#define WordU_addCheckBodyCX(size, c, x, doOverflow, doSuccess) \
+WordU_addCheckBody(size, c, x, doOverflow, doSuccess)
+
+#define WordS_mulCheckBody(size, x, y, doOverflow, doSuccess) \
+ do { \
+ if ((x == (WordS##size)0) || (y == (WordS##size)0)) { \
+ } else \
+ if (x > (WordS## size)0) { \
+ if (y > (WordS##size)0) { \
+ if (x > WordS##size##_quot (WordS##size##_max, y)) { \
+ doOverflow; \
+ } \
+ } else /* (y < (WordS##size)0) */ { \
+ if (y < WordS##size##_quot (WordS##size##_min, x)) { \
+ doOverflow; \
+ } \
+ } \
+ } else /* (x < (WordS##size)0) */ { \
+ if (y > (WordS##size)0) { \
+ if (x < WordS##size##_quot (WordS##size##_min, y)) { \
+ doOverflow; \
+ } \
+ } else /* (y < (WordS##size)0) */ { \
+ if (y < WordS##size##_quot (WordS##size##_max, x)) { \
+ doOverflow; \
+ } \
+ } \
+ } \
+ doSuccess; \
+ } while (0)
+// #undef WordS_mulCheckBody
+#define WordU_mulCheckBody(size, x, y, doOverflow, doSuccess) \
+ do { \
+ if ((x == (WordU##size)0) || (y == (WordU##size)0)) { \
+ } else \
+ if (x > WordU##size##_quot (Word##size##_max, y)) { \
+ doOverflow; \
+ } \
+ doSuccess; \
+ } while (0)
+// #undef WordU_mulCheckBody
+/* #define Word_mulCheckBody(small, large, x, y, doOverflow, doSuccess) \ */
+/* do { \ */
+/* Word##large tmp; \ */
+/* Word##small res; \ */
+/* tmp = ((Word##large)x) * ((Word##large)y); \ */
+/* res = (Word##small)tmp; \ */
+/* if (tmp != res) { \ */
+/* doOverflow; \ */
+/* } \ */
+/* doSuccess; \ */
+/* } while (0) */
+/* #define WordS_mulCheckBody(small, large, x, y, doOverflow, doSuccess) \ */
+/* Word_mulCheckBody(S##small, S##large, x, y, doOverflow, doSuccess) */
+/* #define WordU_mulCheckBody(small, large, x, y, doOverflow, doSuccess) \ */
+/* Word_mulCheckBody(U##small, U##large, x, y, doOverflow, doSuccess) */
+
+#define WordS_negCheckBody(size, x, doOverflow, doSuccess) \
+ do { \
+ if (x == WordS##size##_min) { \
+ doOverflow; \
+ } \
+ doSuccess; \
+ } while (0)
+
+#define WordS_subCheckBodyCX(size, c, x, doOverflow, doSuccess) \
+ do { \
+ if (c >= 0) { \
+ if (x < c - WordS##size##_max) { \
+ doOverflow; \
+ } \
+ } else if (x > c - WordS##size##_min) { \
+ doOverflow; \
+ } \
+ doSuccess; \
+ } while (0)
+#define WordS_subCheckBodyXC(size, x, c, doOverflow, doSuccess) \
+ do { \
+ if (c <= 0) { \
+ if (x > WordS##size##_max + c) { \
+ doOverflow; \
+ } \
+ } else if (x < WordS##size##_min + c) { \
+ doOverflow; \
+ } \
+ doSuccess; \
+ } while (0)
+#define WordS_subCheckBody(size, x, y, doOverflow, doSuccess) \
+WordS_subCheckBodyCX(size, x, y, doOverflow, doSuccess)
+
+
+#define WordS_addCheckOverflows(size) \
+ MLTON_CODEGEN_STATIC_INLINE \
+ Bool WordS##size##_addCheckOverflows (WordS##size x, WordS##size y) { \
+ WordS_addCheckBody(size, x, y, return TRUE, return FALSE); \
+ }
+
+#define WordU_addCheckOverflows(size) \
+ MLTON_CODEGEN_STATIC_INLINE \
+ Bool WordU##size##_addCheckOverflows (WordU##size x, WordU##size y) { \
+ WordU_addCheckBody(size, x, y, return TRUE, return FALSE); \
+ }
+
+#define WordS_mulCheckOverflows(size) \
+ MLTON_CODEGEN_STATIC_INLINE \
+ Bool WordS##size##_mulCheckOverflows (WordS##size x, WordS##size y) { \
+ WordS_mulCheckBody(size, x, y, return TRUE, return FALSE); \
+ }
+#define WordU_mulCheckOverflows(size) \
+ MLTON_CODEGEN_STATIC_INLINE \
+ Bool WordU##size##_mulCheckOverflows (WordU##size x, WordU##size y) { \
+ WordU_mulCheckBody(size, x, y, return TRUE, return FALSE); \
+ }
+
+#define WordS_negCheckOverflows(size) \
+ MLTON_CODEGEN_STATIC_INLINE \
+ Bool WordS##size##_negCheckOverflows (WordS##size x) { \
+ WordS_negCheckBody(size, x, return TRUE, return FALSE); \
+ }
+
+#define WordS_subCheckOverflows(size) \
+ MLTON_CODEGEN_STATIC_INLINE \
+ Bool WordS##size##_subCheckOverflows (WordS##size x, WordS##size y) { \
+ WordS_subCheckBody(size, x, y, return TRUE, return FALSE); \
+ }
+
+#define all(size) \
+WordS_addCheckOverflows(size) \
+WordU_addCheckOverflows(size) \
+WordS_mulCheckOverflows(size) \
+WordU_mulCheckOverflows(size) \
+WordS_negCheckOverflows(size) \
+WordS_subCheckOverflows(size)
+
+all(8)
+all(16)
+all(32)
+all(64)
+
+#undef all
+#undef WordS_subCheckOverflows
+#undef WordS_negCheckOverflows
+#undef WordU_mulCheckOverflows
+#undef WordS_mulCheckOverflows
+#undef WordU_addCheckOverflows
+#undef WordS_addCheckOverflows
Added: mlton/branches/on-20050822-x86_64-branch/runtime/basis/Word/Word-consts.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/basis/Word/Word-consts.h 2006-05-21 23:07:23 UTC (rev 4563)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/Word/Word-consts.h 2006-05-22 15:56:43 UTC (rev 4564)
@@ -0,0 +1,12 @@
+#define WordS8_max (WordS8)0x7F
+#define WordS8_min (WordS8)0x80
+#define WordS16_max (WordS16)0x7FFF
+#define WordS16_min (WordS16)0x8000
+#define WordS32_max (WordS32)0x7FFFFFFF
+#define WordS32_min (WordS32)0x80000000
+#define WordS64_max (WordS64)0x7FFFFFFFFFFFFFFFll
+#define WordS64_min (WordS64)0x8000000000000000ll
+#define Word8_max (Word8)0xFF
+#define Word16_max (Word16)0xFFFF
+#define Word32_max (Word32)0xFFFFFFFF
+#define Word64_max (Word64)0xFFFFFFFFFFFFFFFFull
Added: mlton/branches/on-20050822-x86_64-branch/runtime/basis/Word/Word-ops.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/basis/Word/Word-ops.h 2006-05-21 23:07:23 UTC (rev 4563)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/Word/Word-ops.h 2006-05-22 15:56:43 UTC (rev 4564)
@@ -0,0 +1,92 @@
+
+#ifndef MLTON_CCODEGEN_HIDE
+#define MLTON_CCODEGEN_HIDE(z) z
+#endif
+
+#define binary(kind, name, op) \
+ MLTON_CODEGEN_STATIC_INLINE \
+ Word##kind Word##kind##_##name (Word##kind w1, Word##kind w2) { \
+ return w1 op w2; \
+ }
+
+#define bothBinary(size, name, op) \
+binary (S##size, name, op) \
+binary (U##size, name, op)
+
+#define compare(kind, name, op) \
+ MLTON_CODEGEN_STATIC_INLINE \
+ Bool Word##kind##_##name (Word##kind w1, Word##kind w2) { \
+ return w1 op w2; \
+ }
+
+#define bothCompare(size, name, op) \
+compare (S##size, name, op) \
+compare (U##size, name, op)
+
+#define rol(size) \
+ MLTON_CODEGEN_STATIC_INLINE \
+ Word##size Word##size##_rol (Word##size w1, Word32 w2) { \
+ return (w1 >> (size - w2)) | (w1 << w2); \
+ }
+
+#define ror(size) \
+ MLTON_CODEGEN_STATIC_INLINE \
+ Word##size Word##size##_ror (Word##size w1, Word32 w2) { \
+ return (w1 >> w2) | (w1 << (size - w2)); \
+ } \
+
+#define shift(kind, name, op) \
+ MLTON_CODEGEN_STATIC_INLINE \
+ Word##kind Word##kind##_##name (Word##kind w1, Word32 w2) { \
+ return w1 op w2; \
+ }
+
+#define unary(kind,name, op) \
+ MLTON_CODEGEN_STATIC_INLINE \
+ Word##kind Word##kind##_##name (Word##kind w) { \
+ return op w; \
+ }
+
+#define all(size) \
+binary (size, add, +) \
+binary (size, andb, &) \
+compare (size, equal, ==) \
+bothCompare (size, ge, >=) \
+bothCompare (size, gt, >) \
+bothCompare (size, le, <=) \
+shift (size, lshift, <<) \
+bothCompare (size, lt, <) \
+bothBinary (size, mul, *) \
+unary (size, neg, -) \
+unary (size, notb, ~) \
+/* WordS<N>_quot and WordS<N>_rem can't be inlined with the C-codegen, \
+ * because the gcc optimizer sometimes produces incorrect results \
+ * when one of th arguments is a constant. \
+ */ \
+MLTON_CCODEGEN_HIDE(binary (S##size, quot, /)) \
+MLTON_CCODEGEN_HIDE(binary (S##size, rem, %)) \
+binary (U##size, quot, /) \
+binary (U##size, rem, %) \
+binary (size, orb, |) \
+rol(size) \
+ror(size) \
+/* WordS<N>_rshift isn't ANSI C, because ANSI doesn't guarantee sign \
+ * extension. We use it anyway cause it always seems to work. \
+ */ \
+shift (S##size, rshift, >>) \
+shift (U##size, rshift, >>) \
+binary (size, sub, -) \
+binary (size, xorb, ^) \
+
+all (8)
+all (16)
+all (32)
+all (64)
+
+#undef binary
+#undef bothBinary
+#undef compare
+#undef bothCompare
+#undef unary
+#undef shift
+#undef all
Modified: mlton/branches/on-20050822-x86_64-branch/runtime/basis/Word/Word.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/basis/Word/Word.c 2006-05-21 23:07:23 UTC (rev 4563)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/Word/Word.c 2006-05-22 15:56:43 UTC (rev 4564)
@@ -28,175 +28,6 @@
#error check that C {/,%} correctly implement {quot,rem} from the basis library
#endif
-#define coerce(f, t) \
- t f##_to##t (f x); \
- t f##_to##t (f x) { \
- return (t)x; \
- }
-
-#define bothCoerce(from, to) \
- coerce (Word##S##from, Word##to) \
- coerce (Word##U##from, Word##to)
-
-#define WordS8_max (WordS8)INT8_MAX
-#define WordS8_min (WordS8)INT8_MIN
-#define WordS16_max (WordS16)INT16_MAX
-#define WordS16_min (WordS16)INT16_MIN
-#define WordS32_max (WordS32)INT32_MAX
-#define WordS32_min (WordS32)INT32_MIN
-#define WordS64_max (WordS64)INT64_MAX
-#define WordS64_min (WordS64)INT64_MIN
-#define WordU8_max (WordU8)UINT8_MAX
-#define WordU16_max (WordU16)UINT16_MAX
-#define WordU32_max (WordU32)UINT32_MAX
-#define WordU64_max (WordU64)UINT64_MAX
-
-#define binary(kind, name, op) \
- Word##kind Word##kind##_##name (Word##kind w1, Word##kind w2); \
- Word##kind Word##kind##_##name (Word##kind w1, Word##kind w2) { \
- return w1 op w2; \
- }
-
-#define bothBinary(size, name, op) \
- binary (S##size, name, op) \
- binary (U##size, name, op)
-
-#define SaddCheckOverflows(size) \
- Bool WordS##size##_addCheckOverflows (WordS##size x, WordS##size y) { \
- if (x >= 0) { \
- if (y > WordS##size##_max - x) \
- return TRUE; \
- } else if (y < WordS##size##_min - x) \
- return TRUE; \
- return FALSE; \
- }
-
-#define UaddCheckOverflows(size) \
- Bool WordU##size##_addCheckOverflows (WordU##size x, WordU##size y) { \
- if (y > WordU##size##_max - x) \
- return TRUE; \
- return FALSE; \
- }
-
-#define SmulCheckOverflows(size) \
- Bool WordS##size##_mulCheckOverflows (WordS##size x, WordS##size y) { \
- if ((x == (WordS##size)0) or (y == (WordS##size)0)) \
- return FALSE; \
- if (x > (WordS##size)0) { \
- if (y > (WordS##size)0) { \
- if (x > WordS##size##_quot (WordS##size##_max, y)) \
- return TRUE; \
- return FALSE; \
- } else /* (y < (WordS##size)0) */ { \
- if (y < WordS##size##_quot (WordS##size##_min, x)) \
- return TRUE; \
- return FALSE; \
- } \
- } else /* (x < (WordS##size)0) */ { \
- if (y > (WordS##size)0) { \
- if (x < WordS##size##_quot (WordS##size##_min, y)) \
- return TRUE; \
- return FALSE; \
- } else /* (y < (WordS##size)0) */ { \
- if (y < WordS##size##_quot (WordS##size##_max, x)) \
- return TRUE; \
- return FALSE; \
- } \
- } \
- }
-
-#define negCheckOverflows(size) \
- Bool Word##size##_negCheckOverflows (WordS##size x) { \
- if (x == WordS##size##_min) \
- return TRUE; \
- return FALSE; \
- }
-
-#define SsubCheckOverflows(size) \
- Bool WordS##size##_subCheckOverflows (WordS##size x, WordS##size y) { \
- if (x >= 0) { \
- if (y < x - WordS##size##_max) \
- return TRUE; \
- } else if (y > x - WordS##size##_min) \
- return TRUE; \
- return FALSE; \
- }
-
-#define compare(kind, name, op) \
- Bool Word##kind##_##name (Word##kind w1, Word##kind w2); \
- Bool Word##kind##_##name (Word##kind w1, Word##kind w2) { \
- return w1 op w2; \
- }
-
-#define bothCompare(size, name, op) \
- compare (S##size, name, op) \
- compare (U##size, name, op)
-
-#define unary(kind,name, op) \
- Word##kind Word##kind##_##name (Word##kind w); \
- Word##kind Word##kind##_##name (Word##kind w) { \
- return op w; \
- }
-
-#define shift(kind, name, op) \
- Word##kind Word##kind##_##name (Word##kind w1, Word32 w2); \
- Word##kind Word##kind##_##name (Word##kind w1, Word32 w2) { \
- return w1 op w2; \
- }
-
-#define all(size) \
- binary (size, add, +) \
- SaddCheckOverflows (size) \
- UaddCheckOverflows (size) \
- binary (size, andb, &) \
- compare (size, equal, ==) \
- bothCompare (size, ge, >=) \
- bothCompare (size, gt, >) \
- bothCompare (size, le, <=) \
- shift (size, lshift, <<) \
- bothCompare (size, lt, <) \
- bothBinary (size, mul, *) \
- unary (size, neg, -) \
- negCheckOverflows (size) \
- unary (size, notb, ~) \
- binary (size, orb, |) \
- bothBinary (size, quot, /) \
- SmulCheckOverflows (size) \
- bothBinary (size, rem, %) \
- Word##size Word##size##_rol (Word##size w1, Word32 w2); \
- Word##size Word##size##_rol (Word##size w1, Word32 w2) {\
- return (w1 >> (size - w2)) | (w1 << w2); \
- } \
- Word##size Word##size##_ror (Word##size w1, Word32 w2); \
- Word##size Word##size##_ror (Word##size w1, Word32 w2) {\
- return (w1 >> w2) | (w1 << (size - w2)); \
- } \
- shift (S##size, rshift, >>) \
- shift (U##size, rshift, >>) \
- binary (size, sub, -) \
- SsubCheckOverflows (size) \
- binary (size, xorb, ^) \
- bothCoerce (size, 64) \
- bothCoerce (size, 32) \
- bothCoerce (size, 16) \
- bothCoerce (size, 8)
-
-all (8)
-all (16)
-all (32)
-all (64)
-
-#undef coerce
-#undef bothCoerce
-#undef binary
-#undef bothBinary
-#undef SaddCheckOverflows
-#undef UaddCheckOverflows
-#undef SmulCheckOverflows
-#undef negCheckOverflows
-#undef SsubCheckOverflows
-#undef compare
-#undef bothCompare
-#undef unary
-#undef shift
-#undef all
+#include "Word-consts.h"
+#include "Word-ops.h"
+#include "Word-check.h"
Added: mlton/branches/on-20050822-x86_64-branch/runtime/basis/coerce.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/basis/coerce.c 2006-05-21 23:07:23 UTC (rev 4563)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/coerce.c 2006-05-22 15:56:43 UTC (rev 4564)
@@ -0,0 +1,3 @@
+#include "platform.h"
+
+#include "coerce.h"
Added: mlton/branches/on-20050822-x86_64-branch/runtime/basis/coerce.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/basis/coerce.h 2006-05-21 23:07:23 UTC (rev 4563)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/coerce.h 2006-05-22 15:56:43 UTC (rev 4564)
@@ -0,0 +1,38 @@
+
+#define coerce(f, t) \
+ MLTON_CODEGEN_STATIC_INLINE \
+ t f##_to##t (f x) { \
+ return (t)x; \
+ }
+#define bothFromWordCoerce(from, to) \
+coerce (Word##S##from, to) \
+coerce (Word##U##from, to)
+#define bothToWordCoerce(from, to) \
+coerce (from, Word##S##to) \
+coerce (from, Word##U##to)
+
+#define allWord(size) \
+bothFromWordCoerce(size, Real32) \
+bothFromWordCoerce(size, Real64) \
+bothToWordCoerce(Real32, size) \
+bothToWordCoerce(Real64, size) \
+bothFromWordCoerce(size, Word8) \
+bothFromWordCoerce(size, Word16) \
+bothFromWordCoerce(size, Word32) \
+bothFromWordCoerce(size, Word64)
+
+allWord(8)
+allWord(16)
+allWord(32)
+allWord(64)
+
+#undef all
+#undef bothToWordCoerce
+#undef bothFromWordCoerce
+
+coerce(Real32,Real32)
+coerce(Real32,Real64)
+coerce(Real64,Real32)
+coerce(Real64,Real64)
+
+#undef coerce
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-05-21 23:07:23 UTC (rev 4563)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gen/basis-ffi.def 2006-05-22 15:56:43 UTC (rev 4564)
@@ -36,7 +36,7 @@
IEEEReal.RoundingMode.FE_UPWARD = _const : C_Int.t
IEEEReal.getRoundingMode = _import : unit -> C_Int.t
IEEEReal.setRoundingMode = _import : C_Int.t -> unit
-MLton.bug = _import noreturn : NullString8.t -> unit
+MLton.bug = _import __attribute__((noreturn)) : NullString8.t -> unit
MLton.Itimer.PROF = _const : C_Int.t
MLton.Itimer.REAL = _const : C_Int.t
MLton.Itimer.VIRTUAL = _const : C_Int.t
@@ -579,7 +579,7 @@
Posix.Process.alarm = _import : C_UInt.t -> C_UInt.t
Posix.Process.exece = _import : NullString8.t * NullString8Array.t * NullString8Array.t -> C_Int.t C_Errno.t
Posix.Process.execp = _import : NullString8.t * NullString8Array.t -> C_Int.t C_Errno.t
-Posix.Process.exit = _import noreturn : C_Status.t -> unit
+Posix.Process.exit = _import __attribute__((noreturn)) : C_Status.t -> unit
Posix.Process.exitStatus = _import : C_Status.t -> C_Int.t
Posix.Process.fork = _import : unit -> C_PId.t C_Errno.t
Posix.Process.ifExited = _import : C_Status.t -> Bool.t
@@ -773,66 +773,6 @@
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 static : Real32.t -> Real32.t
-Real32.Math.asin = _import static : Real32.t -> Real32.t
-Real32.Math.atan = _import static : Real32.t -> Real32.t
-Real32.Math.atan2 = _import static : Real32.t * Real32.t -> Real32.t
-Real32.Math.cos = _import static : Real32.t -> Real32.t
-Real32.Math.cosh = _import : Real32.t -> Real32.t
-Real32.Math.e = _symbol : Real32.t
-Real32.Math.exp = _import static : Real32.t -> Real32.t
-Real32.Math.ln = _import static : Real32.t -> Real32.t
-Real32.Math.log10 = _import static : Real32.t -> Real32.t
-Real32.Math.pi = _symbol : Real32.t
-Real32.Math.pow = _import : Real32.t * Real32.t -> Real32.t
-Real32.Math.sin = _import static : Real32.t -> Real32.t
-Real32.Math.sinh = _import : Real32.t -> Real32.t
-Real32.Math.sqrt = _import static : Real32.t -> Real32.t
-Real32.Math.tan = _import static : 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 static : 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 static : Real32.t -> Real32.t
-Real32.signBit = _import : Real32.t -> C_Int.t
-Real32.strto = _import : NullString8.t -> Real32.t
-Real64.Math.acos = _import static : Real64.t -> Real64.t
-Real64.Math.asin = _import static : Real64.t -> Real64.t
-Real64.Math.atan = _import static : Real64.t -> Real64.t
-Real64.Math.atan2 = _import static : Real64.t * Real64.t -> Real64.t
-Real64.Math.cos = _import static : Real64.t -> Real64.t
-Real64.Math.cosh = _import : Real64.t -> Real64.t
-Real64.Math.e = _symbol : Real64.t
-Real64.Math.exp = _import static : Real64.t -> Real64.t
-Real64.Math.ln = _import static : Real64.t -> Real64.t
-Real64.Math.log10 = _import static : Real64.t -> Real64.t
-Real64.Math.pi = _symbol : Real64.t
-Real64.Math.pow = _import : Real64.t * Real64.t -> Real64.t
-Real64.Math.sin = _import static : Real64.t -> Real64.t
-Real64.Math.sinh = _import : Real64.t -> Real64.t
-Real64.Math.sqrt = _import static : Real64.t -> Real64.t
-Real64.Math.tan = _import static : 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 static : 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 static : 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
@@ -911,3 +851,284 @@
Time.usec = _import : unit -> C_SUSeconds.t
Windows.Process.create = _import : NullString8.t * NullString8.t * NullString8.t * C_Fd.t * C_Fd.t * C_Fd.t -> C_PId.t C_Errno.t
Windows.Process.terminate = _import : C_PId.t * C_Signal.t -> C_Int.t C_Errno.t
+##
+Real32.Math.acos = _import MLTON_CODEGEN_STATIC_INLINE : Real32.t -> Real32.t
+Real32.Math.asin = _import MLTON_CODEGEN_STATIC_INLINE : Real32.t -> Real32.t
+Real32.Math.atan = _import MLTON_CODEGEN_STATIC_INLINE : Real32.t -> Real32.t
+Real32.Math.atan2 = _import MLTON_CODEGEN_STATIC_INLINE : Real32.t * Real32.t -> Real32.t
+Real32.Math.cos = _import MLTON_CODEGEN_STATIC_INLINE : Real32.t -> Real32.t
+Real32.Math.cosh = _import MLTON_CODEGEN_STATIC_INLINE : Real32.t -> Real32.t
+Real32.Math.e = _symbol : Real32.t
+Real32.Math.exp = _import MLTON_CODEGEN_STATIC_INLINE : Real32.t -> Real32.t
+Real32.Math.ln = _import MLTON_CODEGEN_STATIC_INLINE : Real32.t -> Real32.t
+Real32.Math.log10 = _import MLTON_CODEGEN_STATIC_INLINE : Real32.t -> Real32.t
+Real32.Math.pi = _symbol : Real32.t
+Real32.Math.pow = _import MLTON_CODEGEN_STATIC_INLINE : Real32.t * Real32.t -> Real32.t
+Real32.Math.sin = _import MLTON_CODEGEN_STATIC_INLINE : Real32.t -> Real32.t
+Real32.Math.sinh = _import MLTON_CODEGEN_STATIC_INLINE : Real32.t -> Real32.t
+Real32.Math.sqrt = _import MLTON_CODEGEN_STATIC_INLINE : Real32.t -> Real32.t
+Real32.Math.tan = _import MLTON_CODEGEN_STATIC_INLINE : Real32.t -> Real32.t
+Real32.Math.tanh = _import MLTON_CODEGEN_STATIC_INLINE : Real32.t -> Real32.t
+Real32.abs = _import MLTON_CODEGEN_STATIC_INLINE : Real32.t -> Real32.t
+Real32.add = _import MLTON_CODEGEN_STATIC_INLINE : Real32.t * Real32.t -> Real32.t
+Real32.class = _import : Real32.t -> C_Int.t
+Real32.div = _import MLTON_CODEGEN_STATIC_INLINE : Real32.t * Real32.t -> Real32.t
+Real32.equal = _import MLTON_CODEGEN_STATIC_INLINE : Real32.t * Real32.t -> Bool.t
+Real32.frexp = _import MLTON_CODEGEN_STATIC_INLINE : 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 MLTON_CODEGEN_STATIC_INLINE : Real32.t * C_Int.t -> Real32.t
+Real32.le = _import MLTON_CODEGEN_STATIC_INLINE : Real32.t * Real32.t -> Bool.t
+Real32.lt = _import MLTON_CODEGEN_STATIC_INLINE : Real32.t * Real32.t -> Bool.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.mul = _import MLTON_CODEGEN_STATIC_INLINE : Real32.t * Real32.t -> Real32.t
+Real32.muladd = _import MLTON_CODEGEN_STATIC_INLINE : Real32.t * Real32.t * Real32.t -> Real32.t
+Real32.mulsub = _import MLTON_CODEGEN_STATIC_INLINE : Real32.t * Real32.t * Real32.t -> Real32.t
+Real32.neg = _import MLTON_CODEGEN_STATIC_INLINE : Real32.t -> Real32.t
+Real32.nextAfter = _import : Real32.t * Real32.t -> Real32.t
+Real32.round = _import MLTON_CODEGEN_STATIC_INLINE : Real32.t -> Real32.t
+Real32.signBit = _import : Real32.t -> C_Int.t
+Real32.strto = _import : NullString8.t -> Real32.t
+Real32.sub = _import MLTON_CODEGEN_STATIC_INLINE : Real32.t * Real32.t -> Real32.t
+Real32.toReal32 = _import MLTON_CODEGEN_STATIC_INLINE : Real32.t -> Real32.t
+Real32.toReal64 = _import MLTON_CODEGEN_STATIC_INLINE : Real32.t -> Real64.t
+Real32.toWordS8 = _import MLTON_CODEGEN_STATIC_INLINE : Real32.t -> Int8.t
+Real32.toWordS16 = _import MLTON_CODEGEN_STATIC_INLINE : Real32.t -> Int16.t
+Real32.toWordS32 = _import MLTON_CODEGEN_STATIC_INLINE : Real32.t -> Int32.t
+Real32.toWordS64 = _import MLTON_CODEGEN_STATIC_INLINE : Real32.t -> Int64.t
+Real32.toWordU8 = _import MLTON_CODEGEN_STATIC_INLINE : Real32.t -> Word8.t
+Real32.toWordU16 = _import MLTON_CODEGEN_STATIC_INLINE : Real32.t -> Word16.t
+Real32.toWordU32 = _import MLTON_CODEGEN_STATIC_INLINE : Real32.t -> Word32.t
+Real32.toWordU64 = _import MLTON_CODEGEN_STATIC_INLINE : Real32.t -> Word64.t
+Real64.Math.acos = _import MLTON_CODEGEN_STATIC_INLINE : Real64.t -> Real64.t
+Real64.Math.asin = _import MLTON_CODEGEN_STATIC_INLINE : Real64.t -> Real64.t
+Real64.Math.atan = _import MLTON_CODEGEN_STATIC_INLINE : Real64.t -> Real64.t
+Real64.Math.atan2 = _import MLTON_CODEGEN_STATIC_INLINE : Real64.t * Real64.t -> Real64.t
+Real64.Math.cos = _import MLTON_CODEGEN_STATIC_INLINE : Real64.t -> Real64.t
+Real64.Math.cosh = _import MLTON_CODEGEN_STATIC_INLINE : Real64.t -> Real64.t
+Real64.Math.e = _symbol : Real64.t
+Real64.Math.exp = _import MLTON_CODEGEN_STATIC_INLINE : Real64.t -> Real64.t
+Real64.Math.ln = _import MLTON_CODEGEN_STATIC_INLINE : Real64.t -> Real64.t
+Real64.Math.log10 = _import MLTON_CODEGEN_STATIC_INLINE : Real64.t -> Real64.t
+Real64.Math.pi = _symbol : Real64.t
+Real64.Math.pow = _import MLTON_CODEGEN_STATIC_INLINE : Real64.t * Real64.t -> Real64.t
+Real64.Math.sin = _import MLTON_CODEGEN_STATIC_INLINE : Real64.t -> Real64.t
+Real64.Math.sinh = _import MLTON_CODEGEN_STATIC_INLINE : Real64.t -> Real64.t
+Real64.Math.sqrt = _import MLTON_CODEGEN_STATIC_INLINE : Real64.t -> Real64.t
+Real64.Math.tan = _import MLTON_CODEGEN_STATIC_INLINE : Real64.t -> Real64.t
+Real64.Math.tanh = _import MLTON_CODEGEN_STATIC_INLINE : Real64.t -> Real64.t
+Real64.abs = _import MLTON_CODEGEN_STATIC_INLINE : Real64.t -> Real64.t
+Real64.add = _import MLTON_CODEGEN_STATIC_INLINE : Real64.t * Real64.t -> Real64.t
+Real64.class = _import : Real64.t -> C_Int.t
+Real64.div = _import MLTON_CODEGEN_STATIC_INLINE : Real64.t * Real64.t -> Real64.t
+Real64.equal = _import MLTON_CODEGEN_STATIC_INLINE : Real64.t * Real64.t -> Bool.t
+Real64.frexp = _import MLTON_CODEGEN_STATIC_INLINE : 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 MLTON_CODEGEN_STATIC_INLINE : Real64.t * C_Int.t -> Real64.t
+Real64.le = _import MLTON_CODEGEN_STATIC_INLINE : Real64.t * Real64.t -> Bool.t
+Real64.lt = _import MLTON_CODEGEN_STATIC_INLINE : Real64.t * Real64.t -> Bool.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.mul = _import MLTON_CODEGEN_STATIC_INLINE : Real64.t * Real64.t -> Real64.t
+Real64.muladd = _import MLTON_CODEGEN_STATIC_INLINE : Real64.t * Real64.t * Real64.t -> Real64.t
+Real64.mulsub = _import MLTON_CODEGEN_STATIC_INLINE : Real64.t * Real64.t * Real64.t -> Real64.t
+Real64.neg = _import MLTON_CODEGEN_STATIC_INLINE : Real64.t -> Real64.t
+Real64.nextAfter = _import : Real64.t * Real64.t -> Real64.t
+Real64.round = _import MLTON_CODEGEN_STATIC_INLINE : Real64.t -> Real64.t
+Real64.signBit = _import : Real64.t -> C_Int.t
+Real64.strto = _import : NullString8.t -> Real64.t
+Real64.sub = _import MLTON_CODEGEN_STATIC_INLINE : Real64.t * Real64.t -> Real64.t
+Real64.toReal32 = _import MLTON_CODEGEN_STATIC_INLINE : Real64.t -> Real32.t
+Real64.toReal64 = _import MLTON_CODEGEN_STATIC_INLINE : Real64.t -> Real64.t
+Real64.toWordS8 = _import MLTON_CODEGEN_STATIC_INLINE : Real64.t -> Int8.t
+Real64.toWordS16 = _import MLTON_CODEGEN_STATIC_INLINE : Real64.t -> Int16.t
+Real64.toWordS32 = _import MLTON_CODEGEN_STATIC_INLINE : Real64.t -> Int32.t
+Real64.toWordS64 = _import MLTON_CODEGEN_STATIC_INLINE : Real64.t -> Int64.t
+Real64.toWordU8 = _import MLTON_CODEGEN_STATIC_INLINE : Real64.t -> Word8.t
+Real64.toWordU16 = _import MLTON_CODEGEN_STATIC_INLINE : Real64.t -> Word16.t
+Real64.toWordU32 = _import MLTON_CODEGEN_STATIC_INLINE : Real64.t -> Word32.t
+Real64.toWordU64 = _import MLTON_CODEGEN_STATIC_INLINE : Real64.t -> Word64.t
+Word8.add = _import MLTON_CODEGEN_STATIC_INLINE : Word8.t * Word8.t -> Word8.t
+Word8.andb = _import MLTON_CODEGEN_STATIC_INLINE : Word8.t * Word8.t -> Word8.t
+Word8.equal = _import MLTON_CODEGEN_STATIC_INLINE : Word8.t * Word8.t -> Bool.t
+Word8.lshift = _import MLTON_CODEGEN_STATIC_INLINE : Word8.t * Word32.t -> Word8.t
+Word8.neg = _import MLTON_CODEGEN_STATIC_INLINE : Word8.t -> Word8.t
+Word8.notb = _import MLTON_CODEGEN_STATIC_INLINE : Word8.t -> Word8.t
+Word8.orb = _import MLTON_CODEGEN_STATIC_INLINE : Word8.t * Word8.t -> Word8.t
+Word8.rol = _import MLTON_CODEGEN_STATIC_INLINE : Word8.t * Word32.t -> Word8.t
+Word8.ror = _import MLTON_CODEGEN_STATIC_INLINE : Word8.t * Word32.t -> Word8.t
+Word8.sub = _import MLTON_CODEGEN_STATIC_INLINE : Word8.t * Word8.t -> Word8.t
+Word8.xorb = _import MLTON_CODEGEN_STATIC_INLINE : Word8.t * Word8.t -> Word8.t
+Word16.add = _import MLTON_CODEGEN_STATIC_INLINE : Word16.t * Word16.t -> Word16.t
+Word16.andb = _import MLTON_CODEGEN_STATIC_INLINE : Word16.t * Word16.t -> Word16.t
+Word16.equal = _import MLTON_CODEGEN_STATIC_INLINE : Word16.t * Word16.t -> Bool.t
+Word16.lshift = _import MLTON_CODEGEN_STATIC_INLINE : Word16.t * Word32.t -> Word16.t
+Word16.neg = _import MLTON_CODEGEN_STATIC_INLINE : Word16.t -> Word16.t
+Word16.notb = _import MLTON_CODEGEN_STATIC_INLINE : Word16.t -> Word16.t
+Word16.orb = _import MLTON_CODEGEN_STATIC_INLINE : Word16.t * Word16.t -> Word16.t
+Word16.rol = _import MLTON_CODEGEN_STATIC_INLINE : Word16.t * Word32.t -> Word16.t
+Word16.ror = _import MLTON_CODEGEN_STATIC_INLINE : Word16.t * Word32.t -> Word16.t
+Word16.sub = _import MLTON_CODEGEN_STATIC_INLINE : Word16.t * Word16.t -> Word16.t
+Word16.xorb = _import MLTON_CODEGEN_STATIC_INLINE : Word16.t * Word16.t -> Word16.t
+Word32.add = _import MLTON_CODEGEN_STATIC_INLINE : Word32.t * Word32.t -> Word32.t
+Word32.andb = _import MLTON_CODEGEN_STATIC_INLINE : Word32.t * Word32.t -> Word32.t
+Word32.equal = _import MLTON_CODEGEN_STATIC_INLINE : Word32.t * Word32.t -> Bool.t
+Word32.lshift = _import MLTON_CODEGEN_STATIC_INLINE : Word32.t * Word32.t -> Word32.t
+Word32.neg = _import MLTON_CODEGEN_STATIC_INLINE : Word32.t -> Word32.t
+Word32.notb = _import MLTON_CODEGEN_STATIC_INLINE : Word32.t -> Word32.t
+Word32.orb = _import MLTON_CODEGEN_STATIC_INLINE : Word32.t * Word32.t -> Word32.t
+Word32.rol = _import MLTON_CODEGEN_STATIC_INLINE : Word32.t * Word32.t -> Word32.t
+Word32.ror = _import MLTON_CODEGEN_STATIC_INLINE : Word32.t * Word32.t -> Word32.t
+Word32.sub = _import MLTON_CODEGEN_STATIC_INLINE : Word32.t * Word32.t -> Word32.t
+Word32.xorb = _import MLTON_CODEGEN_STATIC_INLINE : Word32.t * Word32.t -> Word32.t
+Word64.add = _import MLTON_CODEGEN_STATIC_INLINE : Word64.t * Word64.t -> Word64.t
+Word64.andb = _import MLTON_CODEGEN_STATIC_INLINE : Word64.t * Word64.t -> Word64.t
+Word64.equal = _import MLTON_CODEGEN_STATIC_INLINE : Word64.t * Word64.t -> Bool.t
+Word64.lshift = _import MLTON_CODEGEN_STATIC_INLINE : Word64.t * Word32.t -> Word64.t
+Word64.neg = _import MLTON_CODEGEN_STATIC_INLINE : Word64.t -> Word64.t
+Word64.notb = _import MLTON_CODEGEN_STATIC_INLINE : Word64.t -> Word64.t
+Word64.orb = _import MLTON_CODEGEN_STATIC_INLINE : Word64.t * Word64.t -> Word64.t
+Word64.rol = _import MLTON_CODEGEN_STATIC_INLINE : Word64.t * Word32.t -> Word64.t
+Word64.ror = _import MLTON_CODEGEN_STATIC_INLINE : Word64.t * Word32.t -> Word64.t
+Word64.sub = _import MLTON_CODEGEN_STATIC_INLINE : Word64.t * Word64.t -> Word64.t
+Word64.xorb = _import MLTON_CODEGEN_STATIC_INLINE : Word64.t * Word64.t -> Word64.t
+WordS8.addCheckOverflows = _import MLTON_CODEGEN_STATIC_INLINE : Int8.t * Int8.t -> Bool.t
+WordS8.ge = _import MLTON_CODEGEN_STATIC_INLINE : Int8.t * Int8.t -> Bool.t
+WordS8.gt = _import MLTON_CODEGEN_STATIC_INLINE : Int8.t * Int8.t -> Bool.t
+WordS8.le = _import MLTON_CODEGEN_STATIC_INLINE : Int8.t * Int8.t -> Bool.t
+WordS8.lt = _import MLTON_CODEGEN_STATIC_INLINE : Int8.t * Int8.t -> Bool.t
+WordS8.mul = _import MLTON_CODEGEN_STATIC_INLINE : Int8.t * Int8.t -> Int8.t
+WordS8.mulCheckOverflows = _import MLTON_CODEGEN_STATIC_INLINE : Int8.t * Int8.t -> Bool.t
+WordS8.negCheckOverflows = _import MLTON_CODEGEN_STATIC_INLINE : Int8.t -> Bool.t
+WordS8.quot = _import MLTON_CODEGEN_STATIC_INLINE : Int8.t * Int8.t -> Int8.t
+WordS8.rem = _import MLTON_CODEGEN_STATIC_INLINE : Int8.t * Int8.t -> Int8.t
+WordS8.rshift = _import MLTON_CODEGEN_STATIC_INLINE : Int8.t * Word32.t -> Int8.t
+WordS8.subCheckOverflows = _import MLTON_CODEGEN_STATIC_INLINE : Int8.t * Int8.t -> Bool.t
+WordS8.toReal32 = _import MLTON_CODEGEN_STATIC_INLINE : Int8.t -> Real32.t
+WordS8.toReal64 = _import MLTON_CODEGEN_STATIC_INLINE : Int8.t -> Real64.t
+WordS8.toWord8 = _import MLTON_CODEGEN_STATIC_INLINE : Int8.t -> Word8.t
+WordS8.toWord16 = _import MLTON_CODEGEN_STATIC_INLINE : Int8.t -> Word16.t
+WordS8.toWord32 = _import MLTON_CODEGEN_STATIC_INLINE : Int8.t -> Word32.t
+WordS8.toWord64 = _import MLTON_CODEGEN_STATIC_INLINE : Int8.t -> Word64.t
+WordS16.addCheckOverflows = _import MLTON_CODEGEN_STATIC_INLINE : Int16.t * Int16.t -> Bool.t
+WordS16.ge = _import MLTON_CODEGEN_STATIC_INLINE : Int16.t * Int16.t -> Bool.t
+WordS16.gt = _import MLTON_CODEGEN_STATIC_INLINE : Int16.t * Int16.t -> Bool.t
+WordS16.le = _import MLTON_CODEGEN_STATIC_INLINE : Int16.t * Int16.t -> Bool.t
+WordS16.lt = _import MLTON_CODEGEN_STATIC_INLINE : Int16.t * Int16.t -> Bool.t
+WordS16.mul = _import MLTON_CODEGEN_STATIC_INLINE : Int16.t * Int16.t -> Int16.t
+WordS16.mulCheckOverflows = _import MLTON_CODEGEN_STATIC_INLINE : Int16.t * Int16.t -> Bool.t
+WordS16.negCheckOverflows = _import MLTON_CODEGEN_STATIC_INLINE : Int16.t -> Bool.t
+WordS16.quot = _import MLTON_CODEGEN_STATIC_INLINE : Int16.t * Int16.t -> Int16.t
+WordS16.rem = _import MLTON_CODEGEN_STATIC_INLINE : Int16.t * Int16.t -> Int16.t
+WordS16.rshift = _import MLTON_CODEGEN_STATIC_INLINE : Int16.t * Word32.t -> Int16.t
+WordS16.subCheckOverflows = _import MLTON_CODEGEN_STATIC_INLINE : Int16.t * Int16.t -> Bool.t
+WordS16.toReal32 = _import MLTON_CODEGEN_STATIC_INLINE : Int16.t -> Real32.t
+WordS16.toReal64 = _import MLTON_CODEGEN_STATIC_INLINE : Int16.t -> Real64.t
+WordS16.toWord8 = _import MLTON_CODEGEN_STATIC_INLINE : Int16.t -> Word8.t
+WordS16.toWord16 = _import MLTON_CODEGEN_STATIC_INLINE : Int16.t -> Word16.t
+WordS16.toWord32 = _import MLTON_CODEGEN_STATIC_INLINE : Int16.t -> Word32.t
+WordS16.toWord64 = _import MLTON_CODEGEN_STATIC_INLINE : Int16.t -> Word64.t
+WordS32.addCheckOverflows = _import MLTON_CODEGEN_STATIC_INLINE : Int32.t * Int32.t -> Bool.t
+WordS32.ge = _import MLTON_CODEGEN_STATIC_INLINE : Int32.t * Int32.t -> Bool.t
+WordS32.gt = _import MLTON_CODEGEN_STATIC_INLINE : Int32.t * Int32.t -> Bool.t
+WordS32.le = _import MLTON_CODEGEN_STATIC_INLINE : Int32.t * Int32.t -> Bool.t
+WordS32.lt = _import MLTON_CODEGEN_STATIC_INLINE : Int32.t * Int32.t -> Bool.t
+WordS32.mul = _import MLTON_CODEGEN_STATIC_INLINE : Int32.t * Int32.t -> Int32.t
+WordS32.mulCheckOverflows = _import MLTON_CODEGEN_STATIC_INLINE : Int32.t * Int32.t -> Bool.t
+WordS32.negCheckOverflows = _import MLTON_CODEGEN_STATIC_INLINE : Int32.t -> Bool.t
+WordS32.quot = _import MLTON_CODEGEN_STATIC_INLINE : Int32.t * Int32.t -> Int32.t
+WordS32.rem = _import MLTON_CODEGEN_STATIC_INLINE : Int32.t * Int32.t -> Int32.t
+WordS32.rshift = _import MLTON_CODEGEN_STATIC_INLINE : Int32.t * Word32.t -> Int32.t
+WordS32.subCheckOverflows = _import MLTON_CODEGEN_STATIC_INLINE : Int32.t * Int32.t -> Bool.t
+WordS32.toReal32 = _import MLTON_CODEGEN_STATIC_INLINE : Int32.t -> Real32.t
+WordS32.toReal64 = _import MLTON_CODEGEN_STATIC_INLINE : Int32.t -> Real64.t
+WordS32.toWord8 = _import MLTON_CODEGEN_STATIC_INLINE : Int32.t -> Word8.t
+WordS32.toWord16 = _import MLTON_CODEGEN_STATIC_INLINE : Int32.t -> Word16.t
+WordS32.toWord32 = _import MLTON_CODEGEN_STATIC_INLINE : Int32.t -> Word32.t
+WordS32.toWord64 = _import MLTON_CODEGEN_STATIC_INLINE : Int32.t -> Word64.t
+WordS64.addCheckOverflows = _import MLTON_CODEGEN_STATIC_INLINE : Int64.t * Int64.t -> Bool.t
+WordS64.ge = _import MLTON_CODEGEN_STATIC_INLINE : Int64.t * Int64.t -> Bool.t
+WordS64.gt = _import MLTON_CODEGEN_STATIC_INLINE : Int64.t * Int64.t -> Bool.t
+WordS64.le = _import MLTON_CODEGEN_STATIC_INLINE : Int64.t * Int64.t -> Bool.t
+WordS64.lt = _import MLTON_CODEGEN_STATIC_INLINE : Int64.t * Int64.t -> Bool.t
+WordS64.mul = _import MLTON_CODEGEN_STATIC_INLINE : Int64.t * Int64.t -> Int64.t
+WordS64.mulCheckOverflows = _import MLTON_CODEGEN_STATIC_INLINE : Int64.t * Int64.t -> Bool.t
+WordS64.negCheckOverflows = _import MLTON_CODEGEN_STATIC_INLINE : Int64.t -> Bool.t
+WordS64.quot = _import MLTON_CODEGEN_STATIC_INLINE : Int64.t * Int64.t -> Int64.t
+WordS64.rem = _import MLTON_CODEGEN_STATIC_INLINE : Int64.t * Int64.t -> Int64.t
+WordS64.rshift = _import MLTON_CODEGEN_STATIC_INLINE : Int64.t * Word32.t -> Int64.t
+WordS64.subCheckOverflows = _import MLTON_CODEGEN_STATIC_INLINE : Int64.t * Int64.t -> Bool.t
+WordS64.toReal32 = _import MLTON_CODEGEN_STATIC_INLINE : Int64.t -> Real32.t
+WordS64.toReal64 = _import MLTON_CODEGEN_STATIC_INLINE : Int64.t -> Real64.t
+WordS64.toWord8 = _import MLTON_CODEGEN_STATIC_INLINE : Int64.t -> Word8.t
+WordS64.toWord16 = _import MLTON_CODEGEN_STATIC_INLINE : Int64.t -> Word16.t
+WordS64.toWord32 = _import MLTON_CODEGEN_STATIC_INLINE : Int64.t -> Word32.t
+WordS64.toWord64 = _import MLTON_CODEGEN_STATIC_INLINE : Int64.t -> Word64.t
+WordU8.addCheckOverflows = _import MLTON_CODEGEN_STATIC_INLINE : Word8.t * Word8.t -> Bool.t
+WordU8.ge = _import MLTON_CODEGEN_STATIC_INLINE : Word8.t * Word8.t -> Bool.t
+WordU8.gt = _import MLTON_CODEGEN_STATIC_INLINE : Word8.t * Word8.t -> Bool.t
+WordU8.le = _import MLTON_CODEGEN_STATIC_INLINE : Word8.t * Word8.t -> Bool.t
+WordU8.lt = _import MLTON_CODEGEN_STATIC_INLINE : Word8.t * Word8.t -> Bool.t
+WordU8.mul = _import MLTON_CODEGEN_STATIC_INLINE : Word8.t * Word8.t -> Word8.t
+WordU8.mulCheckOverflows = _import MLTON_CODEGEN_STATIC_INLINE : Word8.t * Word8.t -> Bool.t
+WordU8.quot = _import MLTON_CODEGEN_STATIC_INLINE : Word8.t * Word8.t -> Word8.t
+WordU8.rem = _import MLTON_CODEGEN_STATIC_INLINE : Word8.t * Word8.t -> Word8.t
+WordU8.rshift = _import MLTON_CODEGEN_STATIC_INLINE : Word8.t * Word32.t -> Word8.t
+WordU8.toReal32 = _import MLTON_CODEGEN_STATIC_INLINE : Word8.t -> Real32.t
+WordU8.toReal64 = _import MLTON_CODEGEN_STATIC_INLINE : Word8.t -> Real64.t
+WordU8.toWord8 = _import MLTON_CODEGEN_STATIC_INLINE : Word8.t -> Word8.t
+WordU8.toWord16 = _import MLTON_CODEGEN_STATIC_INLINE : Word8.t -> Word16.t
+WordU8.toWord32 = _import MLTON_CODEGEN_STATIC_INLINE : Word8.t -> Word32.t
+WordU8.toWord64 = _import MLTON_CODEGEN_STATIC_INLINE : Word8.t -> Word64.t
+WordU16.addCheckOverflows = _import MLTON_CODEGEN_STATIC_INLINE : Word16.t * Word16.t -> Bool.t
+WordU16.ge = _import MLTON_CODEGEN_STATIC_INLINE : Word16.t * Word16.t -> Bool.t
+WordU16.gt = _import MLTON_CODEGEN_STATIC_INLINE : Word16.t * Word16.t -> Bool.t
+WordU16.le = _import MLTON_CODEGEN_STATIC_INLINE : Word16.t * Word16.t -> Bool.t
+WordU16.lt = _import MLTON_CODEGEN_STATIC_INLINE : Word16.t * Word16.t -> Bool.t
+WordU16.mul = _import MLTON_CODEGEN_STATIC_INLINE : Word16.t * Word16.t -> Word16.t
+WordU16.mulCheckOverflows = _import MLTON_CODEGEN_STATIC_INLINE : Word16.t * Word16.t -> Bool.t
+WordU16.quot = _import MLTON_CODEGEN_STATIC_INLINE : Word16.t * Word16.t -> Word16.t
+WordU16.rem = _import MLTON_CODEGEN_STATIC_INLINE : Word16.t * Word16.t -> Word16.t
+WordU16.rshift = _import MLTON_CODEGEN_STATIC_INLINE : Word16.t * Word32.t -> Word16.t
+WordU16.toReal32 = _import MLTON_CODEGEN_STATIC_INLINE : Word16.t -> Real32.t
+WordU16.toReal64 = _import MLTON_CODEGEN_STATIC_INLINE : Word16.t -> Real64.t
+WordU16.toWord8 = _import MLTON_CODEGEN_STATIC_INLINE : Word16.t -> Word8.t
+WordU16.toWord16 = _import MLTON_CODEGEN_STATIC_INLINE : Word16.t -> Word16.t
+WordU16.toWord32 = _import MLTON_CODEGEN_STATIC_INLINE : Word16.t -> Word32.t
+WordU16.toWord64 = _import MLTON_CODEGEN_STATIC_INLINE : Word16.t -> Word64.t
+WordU32.addCheckOverflows = _import MLTON_CODEGEN_STATIC_INLINE : Word32.t * Word32.t -> Bool.t
+WordU32.ge = _import MLTON_CODEGEN_STATIC_INLINE : Word32.t * Word32.t -> Bool.t
+WordU32.gt = _import MLTON_CODEGEN_STATIC_INLINE : Word32.t * Word32.t -> Bool.t
+WordU32.le = _import MLTON_CODEGEN_STATIC_INLINE : Word32.t * Word32.t -> Bool.t
+WordU32.lt = _import MLTON_CODEGEN_STATIC_INLINE : Word32.t * Word32.t -> Bool.t
+WordU32.mul = _import MLTON_CODEGEN_STATIC_INLINE : Word32.t * Word32.t -> Word32.t
+WordU32.mulCheckOverflows = _import MLTON_CODEGEN_STATIC_INLINE : Word32.t * Word32.t -> Bool.t
+WordU32.quot = _import MLTON_CODEGEN_STATIC_INLINE : Word32.t * Word32.t -> Word32.t
+WordU32.rem = _import MLTON_CODEGEN_STATIC_INLINE : Word32.t * Word32.t -> Word32.t
+WordU32.rshift = _import MLTON_CODEGEN_STATIC_INLINE : Word32.t * Word32.t -> Word32.t
+WordU32.toReal32 = _import MLTON_CODEGEN_STATIC_INLINE : Word32.t -> Real32.t
+WordU32.toReal64 = _import MLTON_CODEGEN_STATIC_INLINE : Word32.t -> Real64.t
+WordU32.toWord8 = _import MLTON_CODEGEN_STATIC_INLINE : Word32.t -> Word8.t
+WordU32.toWord16 = _import MLTON_CODEGEN_STATIC_INLINE : Word32.t -> Word16.t
+WordU32.toWord32 = _import MLTON_CODEGEN_STATIC_INLINE : Word32.t -> Word32.t
+WordU32.toWord64 = _import MLTON_CODEGEN_STATIC_INLINE : Word32.t -> Word64.t
+WordU64.addCheckOverflows = _import MLTON_CODEGEN_STATIC_INLINE : Word64.t * Word64.t -> Bool.t
+WordU64.ge = _import MLTON_CODEGEN_STATIC_INLINE : Word64.t * Word64.t -> Bool.t
+WordU64.gt = _import MLTON_CODEGEN_STATIC_INLINE : Word64.t * Word64.t -> Bool.t
+WordU64.le = _import MLTON_CODEGEN_STATIC_INLINE : Word64.t * Word64.t -> Bool.t
+WordU64.lt = _import MLTON_CODEGEN_STATIC_INLINE : Word64.t * Word64.t -> Bool.t
+WordU64.mul = _import MLTON_CODEGEN_STATIC_INLINE : Word64.t * Word64.t -> Word64.t
+WordU64.mulCheckOverflows = _import MLTON_CODEGEN_STATIC_INLINE : Word64.t * Word64.t -> Bool.t
+WordU64.quot = _import MLTON_CODEGEN_STATIC_INLINE : Word64.t * Word64.t -> Word64.t
+WordU64.rem = _import MLTON_CODEGEN_STATIC_INLINE : Word64.t * Word64.t -> Word64.t
+WordU64.rshift = _import MLTON_CODEGEN_STATIC_INLINE : Word64.t * Word32.t -> Word64.t
+WordU64.toReal32 = _import MLTON_CODEGEN_STATIC_INLINE : Word64.t -> Real32.t
+WordU64.toReal64 = _import MLTON_CODEGEN_STATIC_INLINE : Word64.t -> Real64.t
+WordU64.toWord8 = _import MLTON_CODEGEN_STATIC_INLINE : Word64.t -> Word8.t
+WordU64.toWord16 = _import MLTON_CODEGEN_STATIC_INLINE : Word64.t -> Word16.t
+WordU64.toWord32 = _import MLTON_CODEGEN_STATIC_INLINE : Word64.t -> Word32.t
+WordU64.toWord64 = _import MLTON_CODEGEN_STATIC_INLINE : Word64.t -> Word64.t
Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gen/gen-basis-ffi.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gen/gen-basis-ffi.sml 2006-05-21 23:07:23 UTC (rev 4563)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gen/gen-basis-ffi.sml 2006-05-22 15:56:43 UTC (rev 4564)
@@ -161,8 +161,7 @@
datatype t =
Const of {name: Name.t,
ty: Type.t}
- | Import of {attr: {noreturn: bool,
- static: bool},
+ | Import of {attrs: string,
name: Name.t,
ty: {args: Type.t list,
ret: Type.t}}
@@ -187,30 +186,16 @@
" ",
Name.toC name,
";"]
- | Import {attr = {noreturn, static}, name, ty = {args, ret}} =>
- let
- val s =
- String.concat
- [Type.toC ret,
- " ",
- Name.toC name,
- "(",
- String.concatWith "," (List.map Type.toC args),
- ")",
- if noreturn
- then " __attribute__ ((noreturn))"
- else "",
- ";"]
- in
- if static
- then String.concat
- ["#if (defined (MLTON_BASIS_FFI_STATIC))\n",
- "static ", s, "\n",
- "#else\n",
- s, "\n",
- "#endif"]
- else s
- end
+ | Import {attrs, name, ty = {args, ret}} =>
+ String.concat
+ [attrs,
+ if String.size attrs > 0 then " " else "",
+ Type.toC ret,
+ " ",
+ Name.toC name,
+ "(",
+ String.concatWith "," (List.map Type.toC args),
+ ");"]
| Symbol {name, ty} =>
String.concat
["extern ",
@@ -229,7 +214,7 @@
"\" : ",
Type.toML ty,
";"]
- | Import {attr, name, ty = {args, ret}} =>
+ | Import {attrs, name, ty = {args, ret}} =>
String.concat
["val ",
Name.last name,
@@ -270,25 +255,15 @@
ty = ret}
end
- fun parseImportAttr (s) =
- let
- fun loop (attr as {noreturn, static}, s) =
- if Substring.isPrefix "noreturn" s
- then loop ({noreturn = true, static = static},
- Substring.droplSpace (#2 (Substring.splitAt (s, 8))))
- else if Substring.isPrefix "static" s
- then loop ({noreturn = noreturn, static = true},
- Substring.droplSpace (#2 (Substring.splitAt (s, 6))))
- else (attr, s)
- in
- loop ({noreturn = false, static = false}, s)
- end
-
fun parseImport (s, name) =
let
val s = #2 (Substring.splitAt (s, 7))
val s = Substring.droplSpace s
- val (attr, s) = parseImportAttr s
+ val (attrs, s) =
+ case CharVectorSlice.findi (fn (_, c) => c = #":") s of
+ NONE => raise Fail (concat ["Entry.parseImport: \"", Substring.string s, "\""])
+ | SOME (i, _) => Substring.splitAt (s, i)
+ val attrs = Substring.droprSpace attrs
val s = if Substring.isPrefix ":" s
then #2 (Substring.splitAt (s, 1))
else raise Fail (concat ["Entry.parseImport: \"", Substring.string s, "\""])
@@ -297,7 +272,7 @@
then ()
else raise Fail (concat ["Entry.parseImport: \"", Substring.string s, "\""])
in
- Import {attr = attr,
+ Import {attrs = Substring.string attrs,
name = name,
ty = {args = args, ret = ret}}
end
@@ -363,7 +338,7 @@
let
val f = TextIO.openOut "basis-ffi.h"
fun print s = TextIO.output (f, s)
- fun println s = (print s; print "\n")
+ fun println s = if s <> "" then (print s; print "\n") else ()
val () = println "/* This file is automatically generated. Do not edit. */\n"
val () = List.app (fn entry => println (Entry.toC entry)) entries
@@ -376,8 +351,14 @@
let
val f = TextIO.openOut "basis-ffi.sml"
fun print s = TextIO.output (f, s)
- fun println s = (print s; print "\n")
+ fun println s = if s <> "" then (print s; print "\n") else ()
+ val primStrs =
+ (List.map (fn n => "Char" ^ n) ["8", "16", "32"]) @
+ (List.map (fn n => "Int" ^ n) ["8", "16", "32", "64"]) @
+ (List.map (fn n => "Real" ^ n) ["32", "64"]) @
+ (List.map (fn n => "Word" ^ n) ["8", "16", "32", "64"])
+
val () = println "(* This file is automatically generated. Do not edit. *)\n"
val () = println "local open Primitive in "
val () = println "structure PrimitiveFFI ="
@@ -394,7 +375,10 @@
| ([], str) =>
List.app (fn s =>
(println ("structure " ^ s ^ " = ")
- ; println "struct"))
+ ; println "struct"
+ ; if List.exists (fn s' => s = s') primStrs
+ then println ("type t = " ^ s ^ ".t")
+ else ()))
str
| (cur, []) =>
List.app (fn _ => println "end") cur
Modified: mlton/branches/on-20050822-x86_64-branch/runtime/platform.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/platform.h 2006-05-21 23:07:23 UTC (rev 4563)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/platform.h 2006-05-22 15:56:43 UTC (rev 4564)
@@ -107,6 +107,9 @@
#include "ml-types.h"
#include "c-types.h"
+#ifndef MLTON_CODEGEN_STATIC_INLINE
+#define MLTON_CODEGEN_STATIC_INLINE /*static inline*/
+#endif
#include "basis-ffi.h"
/* ---------------------------------------------------------------- */
@@ -114,7 +117,7 @@
/* ---------------------------------------------------------------- */
void MLton_init (int argc, char **argv, GC_state s);
-void MLton_exit (GC_state s, C_Int_t status) __attribute__ ((noreturn));
+__attribute__ ((noreturn)) void MLton_exit (GC_state s, C_Int_t status);
/* ---------------------------------------------------------------- */
/* Utility libraries */
@@ -170,7 +173,7 @@
/* MLton */
/* ------------------------------------------------- */
-void MLton_allocTooLarge (void) __attribute__ ((noreturn));
+__attribute__ ((noreturn)) void MLton_allocTooLarge (void);
/* ---------------------------------- */
/* MLton.Platform */
@@ -227,35 +230,4 @@
socklen_t *fromlen);
#endif
-/* ------------------------------------------------- */
-/* Word{8,16,32,64} */
-/* ------------------------------------------------- */
-
-#define SaddCheckOverflows(size) \
- Bool WordS##size##_addCheckOverflows (WordS##size x, WordS##size y);
-#define UaddCheckOverflows(size) \
- Bool WordU##size##_addCheckOverflows (WordU##size x, WordU##size y);
-#define SmulCheckOverflows(size) \
- Bool WordS##size##_mulCheckOverflows (WordS##size x, WordS##size y);
-#define negCheckOverflows(size) \
- Bool Word##size##_negCheckOverflows (WordS##size x);
-#define SsubCheckOverflows(size) \
- Bool WordS##size##_subCheckOverflows (WordS##size x, WordS##size y);
-#define all(size) \
- SaddCheckOverflows (size) \
- UaddCheckOverflows (size) \
- SmulCheckOverflows (size) \
- negCheckOverflows (size) \
- SsubCheckOverflows (size)
-all (8)
-all (16)
-all (32)
-all (64)
-#undef SaddCheckOverflows
-#undef UaddCheckOverflows
-#undef SmulCheckOverflows
-#undef negCheckOverflows
-#undef SsubCheckOverflows
-#undef all
-
#endif /* _MLTON_PLATFORM_H_ */