[MLton-commit] r4378
Matthew Fluet
MLton@mlton.org
Sun, 12 Mar 2006 16:42:45 -0800
A little more work on Real
----------------------------------------------------------------------
U mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/build/sources.mlb
U mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/prim-real.sml
A mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/real/real-global.sml
U mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/real/real.fun
U mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/real/real.sig
U mlton/branches/on-20050822-x86_64-branch/runtime/basis/Int/Word.c
----------------------------------------------------------------------
Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/build/sources.mlb
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/build/sources.mlb 2006-03-06 01:54:59 UTC (rev 4377)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/build/sources.mlb 2006-03-13 00:42:43 UTC (rev 4378)
@@ -159,11 +159,17 @@
(* ../../misc/C.sml *)
../real/math.sig
../real/real.sig
- (* ../../real/real.fun *)
+ ../real/real.fun
../real/pack-real.sig
(* ../real/pack-real.sml *)
(* ../real/real32.sml *)
(* ../real/real64.sml *)
+ local
+ ../config/bind/real-top.sml
+ in ann "forceUsed" in
+ ../config/default/$(DEFAULT_REAL)
+ ../config/default/large-real.sml
+ end end
(*
local
Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/prim-real.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/prim-real.sml 2006-03-06 01:54:59 UTC (rev 4377)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/prim-real.sml 2006-03-13 00:42:43 UTC (rev 4378)
@@ -18,7 +18,7 @@
structure Class :
sig
- type t
+ eqtype t
val inf: t
val nan: t
val normal: t
@@ -74,21 +74,21 @@
val strto: Primitive.NullString8.t -> real
val ~ : real -> real
- val fromInt8: Primitive.Int8.int -> real
- val fromInt16: Primitive.Int16.int -> real
- val fromInt32: Primitive.Int32.int -> real
- val fromInt64: Primitive.Int64.int -> real
+ val fromInt8Unsafe: Primitive.Int8.int -> real
+ val fromInt16Unsafe: Primitive.Int16.int -> real
+ val fromInt32Unsafe: Primitive.Int32.int -> real
+ val fromInt64Unsafe: Primitive.Int64.int -> real
- val fromReal32: Primitive.Real32.real -> real
- val fromReal64: Primitive.Real64.real -> real
+ val fromReal32Unsafe: Primitive.Real32.real -> real
+ val fromReal64Unsafe: Primitive.Real64.real -> real
- val toInt8: real -> Primitive.Int8.int
- val toInt16: real -> Primitive.Int16.int
- val toInt32: real -> Primitive.Int32.int
- val toInt64: real -> Primitive.Int64.int
+ val toInt8Unsafe: real -> Primitive.Int8.int
+ val toInt16Unsafe: real -> Primitive.Int16.int
+ val toInt32Unsafe: real -> Primitive.Int32.int
+ val toInt64Unsafe: real -> Primitive.Int64.int
- val toReal32: real -> Primitive.Real32.real
- val toReal64: real -> Primitive.Real64.real
+ val toReal32Unsafe: real -> Primitive.Real32.real
+ val toReal64Unsafe: real -> Primitive.Real64.real
end
structure Primitive = struct
@@ -161,27 +161,27 @@
val minNormalPos = #1 _symbol "Real32_minNormalPos": real GetSet.t; ()
val minPos = #1 _symbol "Real32_minPos": real GetSet.t; ()
val modf = _import "Real32_modf": real * real ref -> real;
- val nextAfter = _import "Real64_nextAfter": real * real -> real;
- val round = _prim "Real64_round": real -> real;
+ val nextAfter = _import "Real32_nextAfter": real * real -> real;
+ val round = _prim "Real32_round": real -> real;
val signBit = _import "Real32_signBit": real -> C_Int.int;
val strto = _import "Real32_strto": NullString8.t -> real;
val ~ = _prim "Real32_neg": real -> real;
- val fromInt8 = _prim "WordS8_toReal32": Int8.int -> real;
- val fromInt16 = _prim "WordS16_toReal32": Int16.int -> real;
- val fromInt32 = _prim "WordS32_toReal32": Int32.int -> real;
- val fromInt64 = _prim "WordS64_toReal32": Int64.int -> real;
+ val fromInt8Unsafe = _prim "WordS8_toReal32": Int8.int -> real;
+ val fromInt16Unsafe = _prim "WordS16_toReal32": Int16.int -> real;
+ val fromInt32Unsafe = _prim "WordS32_toReal32": Int32.int -> real;
+ val fromInt64Unsafe = _prim "WordS64_toReal32": Int64.int -> real;
- val fromReal32 = _prim "Real32_toReal32": Real32.real -> real;
- val fromReal64 = _prim "Real64_toReal32": Real64.real -> real;
+ val fromReal32Unsafe = _prim "Real32_toReal32": Real32.real -> real;
+ val fromReal64Unsafe = _prim "Real64_toReal32": Real64.real -> real;
- val toInt8 = _prim "Real32_toWordS8": real -> Int8.int;
- val toInt16 = _prim "Real32_toWordS16": real -> Int16.int;
- val toInt32 = _prim "Real32_toWordS32": real -> Int32.int;
- val toInt64 = _prim "Real32_toWordS64": real -> Int64.int;
+ val toInt8Unsafe = _prim "Real32_toWordS8": real -> Int8.int;
+ val toInt16Unsafe = _prim "Real32_toWordS16": real -> Int16.int;
+ val toInt32Unsafe = _prim "Real32_toWordS32": real -> Int32.int;
+ val toInt64Unsafe = _prim "Real32_toWordS64": real -> Int64.int;
- val toReal32 = _prim "Real32_toReal32": real -> Real32.real;
- val toReal64 = _prim "Real32_toReal64": real -> Real64.real;
+ val toReal32Unsafe = _prim "Real32_toReal32": real -> Real32.real;
+ val toReal64Unsafe = _prim "Real32_toReal64": real -> Real64.real;
end
structure Real32 =
struct
@@ -250,21 +250,21 @@
val strto = _import "Real64_strto": NullString8.t -> real;
val ~ = _prim "Real64_neg": real -> real;
- val fromInt8 = _prim "WordS8_toReal64": Int8.int -> real;
- val fromInt16 = _prim "WordS16_toReal64": Int16.int -> real;
- val fromInt32 = _prim "WordS32_toReal64": Int32.int -> real;
- val fromInt64 = _prim "WordS64_toReal64": Int64.int -> real;
+ val fromInt8Unsafe = _prim "WordS8_toReal64": Int8.int -> real;
+ val fromInt16Unsafe = _prim "WordS16_toReal64": Int16.int -> real;
+ val fromInt32Unsafe = _prim "WordS32_toReal64": Int32.int -> real;
+ val fromInt64Unsafe = _prim "WordS64_toReal64": Int64.int -> real;
- val fromReal32 = _prim "Real32_toReal64": Real32.real -> real;
- val fromReal64 = _prim "Real64_toReal64": Real64.real -> real;
+ val fromReal32Unsafe = _prim "Real32_toReal64": Real32.real -> real;
+ val fromReal64Unsafe = _prim "Real64_toReal64": Real64.real -> real;
- val toInt8 = _prim "Real64_toWordS8": real -> Int8.int;
- val toInt16 = _prim "Real64_toWordS16": real -> Int16.int;
- val toInt32 = _prim "Real64_toWordS32": real -> Int32.int;
- val toInt64 = _prim "Real64_toWordS64": real -> Int64.int;
+ val toInt8Unsafe = _prim "Real64_toWordS8": real -> Int8.int;
+ val toInt16Unsafe = _prim "Real64_toWordS16": real -> Int16.int;
+ val toInt32Unsafe = _prim "Real64_toWordS32": real -> Int32.int;
+ val toInt64Unsafe = _prim "Real64_toWordS64": real -> Int64.int;
- val toReal32 = _prim "Real64_toReal32": real -> Real32.real;
- val toReal64 = _prim "Real64_toReal64": real -> Real64.real;
+ val toReal32Unsafe = _prim "Real64_toReal32": real -> Real32.real;
+ val toReal64Unsafe = _prim "Real64_toReal64": real -> Real64.real;
end
structure Real64 =
struct
Copied: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/real/real-global.sml (from rev 4377, mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/int-global.sml)
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/int-global.sml 2006-03-06 01:54:59 UTC (rev 4377)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/real/real-global.sml 2006-03-13 00:42:43 UTC (rev 4378)
@@ -0,0 +1,10 @@
+(* Copyright (C) 1999-2005 Henry Cejtin, Matthew Fluet, Suresh
+ * Jagannathan, and Stephen Weeks.
+ * Copyright (C) 1997-2000 NEC Research Institute.
+ *
+ * MLton is released under a BSD-style license.
+ * See the file MLton-LICENSE for details.
+ *)
+
+structure RealGlobal: REAL_GLOBAL = Real
+open RealGlobal
Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/real/real.fun
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/real/real.fun 2006-03-06 01:54:59 UTC (rev 4377)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/real/real.fun 2006-03-13 00:42:43 UTC (rev 4378)
@@ -5,7 +5,7 @@
* See the file MLton-LICENSE for details.
*)
-functor Real (R: PRE_REAL): REAL =
+functor Real (R: PRE_REAL)(*: REAL*) =
struct
structure MLton = Primitive.MLton
structure Prim = R
@@ -16,7 +16,7 @@
datatype rounding_mode = datatype rounding_mode
end
infix 4 == != ?=
- type real = Prim.real
+ type real = R.real
local
open Prim
@@ -41,21 +41,22 @@
val op >= = op >=
val ~ = ~
val abs = abs
- val fromInt = fromInt
- val fromLarge = fromLarge
+
val maxFinite = maxFinite
val minNormalPos = minNormalPos
val minPos = minPos
- val precision = precision
- val radix = radix
+
+ val precision = Primitive.Int32.toInt precision
+ val radix = Primitive.Int32.toInt radix
+
val signBit = fn r => signBit r <> 0
- val toLarge = toLarge
end
- val zero = fromLarge TO_NEAREST 0.0
- val one = fromLarge TO_NEAREST 1.0
+ val zero = R.fromInt32Unsafe 0
+ val one = R.fromInt32Unsafe 1
+ val two = R.fromInt32Unsafe 2
+
val negOne = ~ one
- val two = fromLarge TO_NEAREST 2.0
val half = one / two
val posInf = one / zero
@@ -66,10 +67,10 @@
local
val classes =
let
- open Primitive.Real64.Class
+ open R.Class
in
- (* order here is chosen based on putting the more commonly used
- * classes at the front.
+ (* order here is chosen based on putting the more
+ * commonly used classes at the front.
*)
[(normal, NORMAL),
(zero, ZERO),
@@ -80,7 +81,7 @@
in
fun class x =
let
- val i = Prim.class x
+ val i = R.class x
in
case List.find (fn (i', _) => i = i') classes of
NONE => raise Fail "Real_class returned bogus integer"
@@ -114,20 +115,20 @@
(NAN, _) => false
| (_, NAN) => false
| (ZERO, ZERO) => true
- | _ => Prim.== (x, y)
+ | _ => R.== (x, y)
val op != = not o op ==
val op ?= =
if MLton.Codegen.isNative
- then Prim.?=
+ then R.?=
else
fn (x, y) =>
case (class x, class y) of
(NAN, _) => true
| (_, NAN) => true
| (ZERO, ZERO) => true
- | _ => Prim.== (x, y)
+ | _ => R.== (x, y)
fun min (x, y) =
if isNan x
@@ -200,32 +201,31 @@
if r == maxFinite andalso t == posInf
then posInf
else if r > t
- then R.nextAfterDown r
- else R.nextAfterUp r
+ then R.nextAfter (r, negInf)
+ else R.nextAfter (r, posInf)
in
if r > zero
then doit (r, t)
else ~ (doit (~r, ~t))
end
- val toManExp =
- let
- val r: int ref = ref 0
- in
- fn x =>
- case class x of
- INF => {exp = 0, man = x}
- | NAN => {exp = 0, man = nan}
- | ZERO => {exp = 0, man = x}
- | _ =>
- let
- val man = Prim.frexp (x, r)
- in
- {exp = !r, man = man}
- end
- end
+ fun toManExp x =
+ case class x of
+ INF => {exp = 0, man = x}
+ | NAN => {exp = 0, man = nan}
+ | ZERO => {exp = 0, man = x}
+ | _ =>
+ let
+ val r: C_Int.t ref = ref 0
+ val man = R.frexp (x, r)
+ in
+ {exp = C_Int.toInt (!r), man = man}
+ end
- fun fromManExp {exp, man} = Prim.ldexp (man, exp)
+ fun fromManExp {exp, man} =
+ (R.ldexp (man, C_Int.fromInt exp))
+ handle Overflow =>
+ man * (if Int.< (exp, 0) then zero else posInf)
val fromManExp =
if MLton.Codegen.isNative
@@ -238,31 +238,28 @@
| ZERO => man
| _ => fromManExp {exp = exp, man = man}
- local
- val int = ref zero
- in
- fun split x =
- case class x of
- INF => {frac = if x > zero then zero else ~zero,
- whole = x}
- | NAN => {frac = nan, whole = nan}
- | _ =>
- let
- val frac = Prim.modf (x, int)
- val whole = !int
- (* Some platforms' C libraries don't get sign of zero right.
- *)
- fun fix y =
- if class y = ZERO
- andalso not (sameSign (x, y))
- then ~ y
+ fun split x =
+ case class x of
+ INF => {frac = if x > zero then zero else ~zero,
+ whole = x}
+ | NAN => {frac = nan, whole = nan}
+ | _ =>
+ let
+ val int = ref zero
+ val frac = R.modf (x, int)
+ val whole = !int
+ (* Some platforms' C libraries don't get sign of
+ * zero right.
+ *)
+ fun fix y =
+ if class y = ZERO andalso not (sameSign (x, y))
+ then ~ y
else y
- in
- {frac = fix frac,
- whole = fix whole}
- end
- end
-
+ in
+ {frac = fix frac,
+ whole = fix whole}
+ end
+
val realMod = #frac o split
fun checkFloat x =
@@ -270,47 +267,123 @@
INF => raise Overflow
| NAN => raise Div
| _ => x
+
+ local
+ fun 'a make {fromRealUnsafe: 'a -> real,
+ toRealUnsafe: real -> 'a,
+ other : {precision: Primitive.Int32.int}} =
+ if R.precision = #precision other
+ then (fromRealUnsafe,
+ fn (m: rounding_mode) => fromRealUnsafe,
+ toRealUnsafe,
+ fn (m: rounding_mode) => toRealUnsafe)
+ else (fromRealUnsafe,
+ fn (m: rounding_mode) => fn r =>
+ IEEEReal.withRoundingMode (m, fn () => fromRealUnsafe r),
+ toRealUnsafe,
+ fn (m: rounding_mode) => fn r =>
+ IEEEReal.withRoundingMode (m, fn () => toRealUnsafe r))
+ in
+ val (fromReal32,fromReal32M,toReal32,toReal32M) =
+ make {fromRealUnsafe = R.fromReal32Unsafe,
+ toRealUnsafe = R.toReal32Unsafe,
+ other = {precision = Primitive.Real32.precision}}
+ val (fromReal64,fromReal64M,toReal64,toReal64M) =
+ make {fromRealUnsafe = R.fromReal64Unsafe,
+ toRealUnsafe = R.toReal64Unsafe,
+ other = {precision = Primitive.Real64.precision}}
+ end
+ local
+ structure S =
+ LargeReal_ChooseRealN
+ (type 'a t = real -> 'a
+ val fReal32 = toReal32
+ val fReal64 = toReal64)
+ in
+ val toLarge = S.f
+ end
+ local
+ structure S =
+ LargeReal_ChooseRealN
+ (type 'a t = rounding_mode -> 'a -> real
+ val fReal32 = fromReal32M
+ val fReal64 = fromReal64M)
+ in
+ val fromLarge = S.f
+ end
- val maxInt = fromInt Int.maxInt'
- val minInt = fromInt Int.minInt'
+ fun roundReal (x: real, m: rounding_mode): real =
+ IEEEReal.withRoundingMode (m, fn () => R.round x)
- fun roundReal (x: real, m: rounding_mode): real =
- fromLarge
- TO_NEAREST
- (IEEEReal.withRoundingMode (m, fn () =>
- (Primitive.Real64.round (toLarge x))))
-
- fun toInt mode x =
- case class x of
- INF => raise Overflow
- | NAN => raise Domain
- | _ =>
- if minInt <= x
- then if x <= maxInt
- then Prim.toInt (roundReal (x, mode))
- else if x < maxInt + one
- then (case mode of
- TO_NEGINF => Int.maxInt'
- | TO_POSINF => raise Overflow
- | TO_ZERO => Int.maxInt'
- | TO_NEAREST =>
- (* Depends on maxInt being odd. *)
- if x - maxInt >= half
- then raise Overflow
- else Int.maxInt')
- else raise Overflow
- else if x > minInt - one
- then (case mode of
- TO_NEGINF => raise Overflow
- | TO_POSINF => Int.minInt'
- | TO_ZERO => Int.minInt'
- | TO_NEAREST =>
- (* Depends on minInt being even. *)
- if x - minInt < ~half
- then raise Overflow
- else Int.minInt')
- else raise Overflow
-
+ local
+ fun 'a make {fromIntUnsafe: 'a -> real,
+ toIntUnsafe: real -> 'a,
+ other : {maxInt': 'a,
+ minInt': 'a}} =
+ let
+ val maxInt' = #maxInt' other
+ val minInt' = #minInt' other
+ val maxInt = fromIntUnsafe maxInt'
+ val minInt = fromIntUnsafe minInt'
+ in
+ (fromIntUnsafe,
+ fn (m: rounding_mode) => fn i =>
+ IEEEReal.withRoundingMode (m, fn () => fromIntUnsafe i),
+ toIntUnsafe,
+ fn (m: rounding_mode) => fn x =>
+ case class x of
+ INF => raise Overflow
+ | NAN => raise Domain
+ | _ => if minInt <= x
+ then if x <= maxInt
+ then toIntUnsafe (roundReal (x, m))
+ else if x < maxInt + one
+ then (case m of
+ TO_NEGINF => maxInt'
+ | TO_POSINF => raise Overflow
+ | TO_ZERO => maxInt'
+ | TO_NEAREST =>
+ (* Depends on maxInt being odd. *)
+ if x - maxInt >= half
+ then raise Overflow
+ else maxInt')
+ else raise Overflow
+ else if x > minInt - one
+ then (case m of
+ TO_NEGINF => raise Overflow
+ | TO_POSINF => minInt'
+ | TO_ZERO => minInt'
+ | TO_NEAREST =>
+ (* Depends on minInt being even. *)
+ if x - minInt < ~half
+ then raise Overflow
+ else minInt')
+ else raise Overflow)
+ end
+ in
+ val (fromInt8,fromInt8M,toInt8,toInt8M) =
+ make {fromIntUnsafe = R.fromInt8Unsafe,
+ toIntUnsafe = R.toInt8Unsafe,
+ other = {maxInt' = Int8.maxInt',
+ minInt' = Int8.minInt'}}
+ val (fromInt16,fromInt16M,toInt16,toInt16M) =
+ make {fromIntUnsafe = R.fromInt16Unsafe,
+ toIntUnsafe = R.toInt16Unsafe,
+ other = {maxInt' = Int16.maxInt',
+ minInt' = Int16.minInt'}}
+ val (fromInt32,fromInt32M,toInt32,toInt32M) =
+ make {fromIntUnsafe = R.fromInt32Unsafe,
+ toIntUnsafe = R.toInt32Unsafe,
+ other = {maxInt' = Int32.maxInt',
+ minInt' = Int32.minInt'}}
+ val (fromInt64,fromInt64M,toInt64,toInt64M) =
+ make {fromIntUnsafe = R.fromInt64Unsafe,
+ toIntUnsafe = R.toInt64Unsafe,
+ other = {maxInt' = Int64.maxInt',
+ minInt' = Int64.minInt'}}
+ end
+
+(*
val floor = toInt TO_NEGINF
val ceil = toInt TO_POSINF
val trunc = toInt TO_ZERO
@@ -779,4 +852,8 @@
| ZERO => x
| _ => R.Math.tanh x
end
+*)
end
+
+structure Real32 = Real (Primitive.Real32)
+structure Real64 = Real (Primitive.Real64)
Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/real/real.sig
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/real/real.sig 2006-03-06 01:54:59 UTC (rev 4377)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/real/real.sig 2006-03-13 00:42:43 UTC (rev 4378)
@@ -8,6 +8,16 @@
sig
include PRE_REAL_GLOBAL
+ structure Class :
+ sig
+ eqtype t
+ val inf: t
+ val nan: t
+ val normal: t
+ val subnormal: t
+ val zero: t
+ end
+
val * : real * real -> real
val *+ : real * real * real -> real
val *- : real * real * real -> real
@@ -22,24 +32,47 @@
val ?= : real * real -> bool
val ~ : real -> real
val abs: real -> real
- val class: real -> int
- val frexp: real * int ref -> real
- val gdtoa: real * int * int * int ref -> C_String.t
- val fromInt: int -> real
- val fromLarge: IEEEReal.rounding_mode -> LargeReal.real -> real
- val ldexp: real * int -> real
+
val maxFinite: real
val minNormalPos: real
val minPos: real
+
+ val precision: Primitive.Int32.int
+ val radix: Primitive.Int32.int
+
+ val signBit: real -> C_Int.t
+
+ val class: real -> Class.t
+
+ val nextAfter: real * real -> real
+
+ val frexp: real * C_Int.int ref -> real
+ val ldexp: real * C_Int.int -> real
val modf: real * real ref -> real
+
+ val round: real -> real
+(*
+ val gdtoa: real * int * int * int ref -> C_String.t
val nextAfterDown: real -> real
val nextAfterUp: real -> real
- val precision: int
- val radix: int
- val signBit: real -> int
val strto: NullString.t -> real
- val toInt: real -> int
- val toLarge: real -> LargeReal.real
+*)
+
+ val fromInt8Unsafe: Primitive.Int8.int -> real
+ val fromInt16Unsafe: Primitive.Int16.int -> real
+ val fromInt32Unsafe: Primitive.Int32.int -> real
+ val fromInt64Unsafe: Primitive.Int64.int -> real
+
+ val fromReal32Unsafe: Primitive.Real32.real -> real
+ val fromReal64Unsafe: Primitive.Real64.real -> real
+
+ val toInt8Unsafe: real -> Primitive.Int8.int
+ val toInt16Unsafe: real -> Primitive.Int16.int
+ val toInt32Unsafe: real -> Primitive.Int32.int
+ val toInt64Unsafe: real -> Primitive.Int64.int
+
+ val toReal32Unsafe: real -> Primitive.Real32.real
+ val toReal64Unsafe: real -> Primitive.Real64.real
end
signature REAL_GLOBAL =
Modified: mlton/branches/on-20050822-x86_64-branch/runtime/basis/Int/Word.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/basis/Int/Word.c 2006-03-06 01:54:59 UTC (rev 4377)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/Int/Word.c 2006-03-13 00:42:43 UTC (rev 4378)
@@ -139,8 +139,8 @@
}
#define shift(kind, name, op) \
- Word##kind Word##kind##_##name (Word##kind w1, Word w2); \
- Word##kind Word##kind##_##name (Word##kind w1, Word w2) { \
+ Word##kind Word##kind##_##name (Word##kind w1, Word32 w2); \
+ Word##kind Word##kind##_##name (Word##kind w1, Word32 w2) { \
return w1 op w2; \
}
@@ -163,12 +163,12 @@
bothBinary (size, quot, /) \
SmulCheckOverflows (size) \
bothBinary (size, rem, %) \
- Word##size Word##size##_rol (Word##size w1, Word w2); \
- Word##size Word##size##_rol (Word##size w1, Word w2) { \
+ 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, Word w2); \
- Word##size Word##size##_ror (Word##size w1, Word 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, >>) \