[MLton-commit] r5426
Matthew Fluet
fluet at mlton.org
Tue Mar 13 18:24:44 PST 2007
Implement byte swap in ML.
Implement PackWord{Big,Little} using ML byte swap functions.
Eliminate PackWord C functions.
----------------------------------------------------------------------
U mlton/branches/on-20050822-x86_64-branch/basis-library/integer/pack-word.sml
U mlton/branches/on-20050822-x86_64-branch/basis-library/integer/word.sig
U mlton/branches/on-20050822-x86_64-branch/basis-library/integer/word.sml
U mlton/branches/on-20050822-x86_64-branch/basis-library/mlton/word.sig
U mlton/branches/on-20050822-x86_64-branch/basis-library/primitive/basis-ffi.sml
D mlton/branches/on-20050822-x86_64-branch/basis-library/primitive/check-pack-word.sml
U mlton/branches/on-20050822-x86_64-branch/basis-library/primitive/primitive.mlb
D mlton/branches/on-20050822-x86_64-branch/runtime/basis/Word/PackWord.c
U mlton/branches/on-20050822-x86_64-branch/runtime/basis-ffi.h
U mlton/branches/on-20050822-x86_64-branch/runtime/gen/basis-ffi.def
U mlton/branches/on-20050822-x86_64-branch/runtime/gen/basis-ffi.h
U mlton/branches/on-20050822-x86_64-branch/runtime/gen/basis-ffi.sml
----------------------------------------------------------------------
Modified: mlton/branches/on-20050822-x86_64-branch/basis-library/integer/pack-word.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library/integer/pack-word.sml 2007-03-14 01:37:13 UTC (rev 5425)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/integer/pack-word.sml 2007-03-14 02:24:42 UTC (rev 5426)
@@ -11,11 +11,9 @@
val wordSize: int
val isBigEndian: bool
val subArr: Word8.word array * SeqIndex.int -> word
- val subArrRev: Word8.word array * C_Ptrdiff.t -> word
val subVec: Word8.word vector * SeqIndex.int -> word
- val subVecRev: Word8.word vector * C_Ptrdiff.t -> word
val update: Word8.word array * SeqIndex.int * word -> unit
- val updateRev: Word8.word array * C_Ptrdiff.t * word -> unit
+ val bswap: word -> word
val toLarge: word -> LargeWord.word
val toLargeX: word -> LargeWord.word
val fromLarge: LargeWord.word -> word
@@ -26,21 +24,8 @@
val bytesPerElem = Int.div (wordSize, 8)
-fun offsetForC (i, n) =
+fun offset (i, n) =
let
- val i = Int.* (bytesPerElem, i)
- val () =
- if Primitive.Controls.safe
- andalso (Int.geu (Int.+ (i, Int.- (bytesPerElem, 1)), n))
- then raise Subscript
- else ()
- in
- C_Ptrdiff.fromInt i
- end
- handle Overflow => raise Subscript
-
-fun offsetForML (i, n) =
- let
val i' = Int.* (bytesPerElem, i)
val () =
if Primitive.Controls.safe
@@ -52,10 +37,14 @@
end
handle Overflow => raise Subscript
-val (subA, subV, updA, offset) =
+val subArrRev = bswap o subArr
+val subVecRev = bswap o subVec
+fun updateRev (a, i, w) = update (a, i, bswap w)
+
+val (subA, subV, updA) =
if isBigEndian = Primitive.MLton.Platform.Arch.hostIsBigEndian
- then (subArr, subVec, update, offsetForML)
- else (subArrRev, subVecRev, updateRev, offsetForC)
+ then (subArr, subVec, update)
+ else (subArrRev, subVecRev, updateRev)
fun update (a, i, w) =
let
@@ -97,73 +86,61 @@
structure PackWord8Big: PACK_WORD =
PackWord (val wordSize = Word8.wordSize
val isBigEndian = true
- open PrimitiveFFI.PackWord8
open Primitive.PackWord8
open Word8)
structure PackWord8Little: PACK_WORD =
PackWord (val wordSize = Word8.wordSize
val isBigEndian = false
- open PrimitiveFFI.PackWord8
open Primitive.PackWord8
open Word8)
structure PackWord8Host: PACK_WORD =
PackWord (val wordSize = Word8.wordSize
val isBigEndian = Primitive.MLton.Platform.Arch.hostIsBigEndian
- open PrimitiveFFI.PackWord8
open Primitive.PackWord8
open Word8)
structure PackWord16Big: PACK_WORD =
PackWord (val wordSize = Word16.wordSize
val isBigEndian = true
- open PrimitiveFFI.PackWord16
open Primitive.PackWord16
open Word16)
structure PackWord16Little: PACK_WORD =
PackWord (val wordSize = Word16.wordSize
val isBigEndian = false
- open PrimitiveFFI.PackWord16
open Primitive.PackWord16
open Word16)
structure PackWord16Host: PACK_WORD =
PackWord (val wordSize = Word16.wordSize
val isBigEndian = Primitive.MLton.Platform.Arch.hostIsBigEndian
- open PrimitiveFFI.PackWord16
open Primitive.PackWord16
open Word16)
structure PackWord32Big: PACK_WORD =
PackWord (val wordSize = Word32.wordSize
val isBigEndian = true
- open PrimitiveFFI.PackWord32
open Primitive.PackWord32
open Word32)
structure PackWord32Little: PACK_WORD =
PackWord (val wordSize = Word32.wordSize
val isBigEndian = false
- open PrimitiveFFI.PackWord32
open Primitive.PackWord32
open Word32)
structure PackWord32Host: PACK_WORD =
PackWord (val wordSize = Word32.wordSize
val isBigEndian = Primitive.MLton.Platform.Arch.hostIsBigEndian
- open PrimitiveFFI.PackWord32
open Primitive.PackWord32
open Word32)
structure PackWord64Big: PACK_WORD =
PackWord (val wordSize = Word64.wordSize
val isBigEndian = true
- open PrimitiveFFI.PackWord64
open Primitive.PackWord64
open Word64)
structure PackWord64Little: PACK_WORD =
PackWord (val wordSize = Word64.wordSize
val isBigEndian = false
- open PrimitiveFFI.PackWord64
open Primitive.PackWord64
open Word64)
structure PackWord64Host: PACK_WORD =
PackWord (val wordSize = Word64.wordSize
val isBigEndian = Primitive.MLton.Platform.Arch.hostIsBigEndian
- open PrimitiveFFI.PackWord64
open Primitive.PackWord64
open Word64)
local
@@ -184,69 +161,36 @@
local
structure S =
Word_ChooseWordN
- (type 'a t = Word8.word array * C_Ptrdiff.t -> 'a
- val fWord8 = PrimitiveFFI.PackWord8.subArr
- val fWord16 = PrimitiveFFI.PackWord16.subArr
- val fWord32 = PrimitiveFFI.PackWord32.subArr
- val fWord64 = PrimitiveFFI.PackWord64.subArr)
+ (type 'a t = Word8.word array * SeqIndex.t -> 'a
+ val fWord8 = Primitive.PackWord8.subArr
+ val fWord16 = Primitive.PackWord16.subArr
+ val fWord32 = Primitive.PackWord32.subArr
+ val fWord64 = Primitive.PackWord64.subArr)
in
val subArr = S.f
end
local
structure S =
Word_ChooseWordN
- (type 'a t = Word8.word array * C_Ptrdiff.t -> 'a
- val fWord8 = PrimitiveFFI.PackWord8.subArrRev
- val fWord16 = PrimitiveFFI.PackWord16.subArrRev
- val fWord32 = PrimitiveFFI.PackWord32.subArrRev
- val fWord64 = PrimitiveFFI.PackWord64.subArrRev)
+ (type 'a t = Word8.word vector * SeqIndex.t -> 'a
+ val fWord8 = Primitive.PackWord8.subVec
+ val fWord16 = Primitive.PackWord16.subVec
+ val fWord32 = Primitive.PackWord32.subVec
+ val fWord64 = Primitive.PackWord64.subVec)
in
- val subArrRev = S.f
- end
- local
- structure S =
- Word_ChooseWordN
- (type 'a t = Word8.word vector * C_Ptrdiff.t -> 'a
- val fWord8 = PrimitiveFFI.PackWord8.subVec
- val fWord16 = PrimitiveFFI.PackWord16.subVec
- val fWord32 = PrimitiveFFI.PackWord32.subVec
- val fWord64 = PrimitiveFFI.PackWord64.subVec)
- in
val subVec = S.f
end
local
structure S =
Word_ChooseWordN
- (type 'a t = Word8.word vector * C_Ptrdiff.t -> 'a
- val fWord8 = PrimitiveFFI.PackWord8.subVecRev
- val fWord16 = PrimitiveFFI.PackWord16.subVecRev
- val fWord32 = PrimitiveFFI.PackWord32.subVecRev
- val fWord64 = PrimitiveFFI.PackWord64.subVecRev)
+ (type 'a t = Word8.word array * SeqIndex.t * 'a -> unit
+ val fWord8 = Primitive.PackWord8.update
+ val fWord16 = Primitive.PackWord16.update
+ val fWord32 = Primitive.PackWord32.update
+ val fWord64 = Primitive.PackWord64.update)
in
- val subVecRev = S.f
- end
- local
- structure S =
- Word_ChooseWordN
- (type 'a t = Word8.word array * C_Ptrdiff.t * 'a -> unit
- val fWord8 = PrimitiveFFI.PackWord8.update
- val fWord16 = PrimitiveFFI.PackWord16.update
- val fWord32 = PrimitiveFFI.PackWord32.update
- val fWord64 = PrimitiveFFI.PackWord64.update)
- in
val update = S.f
end
- local
- structure S =
- Word_ChooseWordN
- (type 'a t = Word8.word array * C_Ptrdiff.t * 'a -> unit
- val fWord8 = PrimitiveFFI.PackWord8.updateRev
- val fWord16 = PrimitiveFFI.PackWord16.updateRev
- val fWord32 = PrimitiveFFI.PackWord32.updateRev
- val fWord64 = PrimitiveFFI.PackWord64.updateRev)
- in
- val updateRev = S.f
- end
end
in
structure PackWordBig: PACK_WORD =
@@ -283,69 +227,36 @@
local
structure S =
LargeWord_ChooseWordN
- (type 'a t = Word8.word array * C_Ptrdiff.t -> 'a
- val fWord8 = PrimitiveFFI.PackWord8.subArr
- val fWord16 = PrimitiveFFI.PackWord16.subArr
- val fWord32 = PrimitiveFFI.PackWord32.subArr
- val fWord64 = PrimitiveFFI.PackWord64.subArr)
+ (type 'a t = Word8.word array * SeqIndex.t -> 'a
+ val fWord8 = Primitive.PackWord8.subArr
+ val fWord16 = Primitive.PackWord16.subArr
+ val fWord32 = Primitive.PackWord32.subArr
+ val fWord64 = Primitive.PackWord64.subArr)
in
val subArr = S.f
end
local
structure S =
LargeWord_ChooseWordN
- (type 'a t = Word8.word array * C_Ptrdiff.t -> 'a
- val fWord8 = PrimitiveFFI.PackWord8.subArrRev
- val fWord16 = PrimitiveFFI.PackWord16.subArrRev
- val fWord32 = PrimitiveFFI.PackWord32.subArrRev
- val fWord64 = PrimitiveFFI.PackWord64.subArrRev)
+ (type 'a t = Word8.word vector * SeqIndex.t -> 'a
+ val fWord8 = Primitive.PackWord8.subVec
+ val fWord16 = Primitive.PackWord16.subVec
+ val fWord32 = Primitive.PackWord32.subVec
+ val fWord64 = Primitive.PackWord64.subVec)
in
- val subArrRev = S.f
- end
- local
- structure S =
- LargeWord_ChooseWordN
- (type 'a t = Word8.word vector * C_Ptrdiff.t -> 'a
- val fWord8 = PrimitiveFFI.PackWord8.subVec
- val fWord16 = PrimitiveFFI.PackWord16.subVec
- val fWord32 = PrimitiveFFI.PackWord32.subVec
- val fWord64 = PrimitiveFFI.PackWord64.subVec)
- in
val subVec = S.f
end
local
structure S =
LargeWord_ChooseWordN
- (type 'a t = Word8.word vector * C_Ptrdiff.t -> 'a
- val fWord8 = PrimitiveFFI.PackWord8.subVecRev
- val fWord16 = PrimitiveFFI.PackWord16.subVecRev
- val fWord32 = PrimitiveFFI.PackWord32.subVecRev
- val fWord64 = PrimitiveFFI.PackWord64.subVecRev)
+ (type 'a t = Word8.word array * SeqIndex.t * 'a -> unit
+ val fWord8 = Primitive.PackWord8.update
+ val fWord16 = Primitive.PackWord16.update
+ val fWord32 = Primitive.PackWord32.update
+ val fWord64 = Primitive.PackWord64.update)
in
- val subVecRev = S.f
- end
- local
- structure S =
- LargeWord_ChooseWordN
- (type 'a t = Word8.word array * C_Ptrdiff.t * 'a -> unit
- val fWord8 = PrimitiveFFI.PackWord8.update
- val fWord16 = PrimitiveFFI.PackWord16.update
- val fWord32 = PrimitiveFFI.PackWord32.update
- val fWord64 = PrimitiveFFI.PackWord64.update)
- in
val update = S.f
end
- local
- structure S =
- LargeWord_ChooseWordN
- (type 'a t = Word8.word array * C_Ptrdiff.t * 'a -> unit
- val fWord8 = PrimitiveFFI.PackWord8.updateRev
- val fWord16 = PrimitiveFFI.PackWord16.updateRev
- val fWord32 = PrimitiveFFI.PackWord32.updateRev
- val fWord64 = PrimitiveFFI.PackWord64.updateRev)
- in
- val updateRev = S.f
- end
end
in
structure PackLargeWordBig: PACK_WORD =
Modified: mlton/branches/on-20050822-x86_64-branch/basis-library/integer/word.sig
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library/integer/word.sig 2007-03-14 01:37:13 UTC (rev 5425)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/integer/word.sig 2007-03-14 02:24:42 UTC (rev 5426)
@@ -66,6 +66,7 @@
val toWordX: word -> Word.word
val fromWord: Word.word -> word
+ val bswap: word -> word
val rol: word * Word.word -> word
val ror: word * Word.word -> word
val log2 : word -> Primitive.Int32.int
Modified: mlton/branches/on-20050822-x86_64-branch/basis-library/integer/word.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library/integer/word.sml 2007-03-14 01:37:13 UTC (rev 5425)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/integer/word.sml 2007-03-14 02:24:42 UTC (rev 5426)
@@ -30,6 +30,27 @@
fun rol (i, n) = W.rolUnsafe (i, Primitive.Word32.zextdFromWord n)
fun ror (i, n) = W.rorUnsafe (i, Primitive.Word32.zextdFromWord n)
+local
+ fun st (w, msk, sft) =
+ let
+ val odd = andb (w, msk)
+ val evn = xorb (w, odd)
+ in
+ (xorb (W.<<? (odd, sft), W.>>? (evn, sft)),
+ xorb (msk, W.<<? (msk, Primitive.Word32.>>? (sft, 0w1))),
+ Primitive.Word32.>>? (sft, 0w1))
+ end
+ val (f, sft) =
+ case W.sizeInBitsWord of
+ 0w8 => (fn x => x, 0w4)
+ | 0w16 => (st, 0w8)
+ | 0w32 => (st o st, 0w16)
+ | 0w64 => (st o st o st, 0w32)
+ | _ => raise (Fail "Word.bswap")
+in
+ fun bswap w = #1 (f (w, W.<<? (one, sft) - one, sft))
+end
+
val fromInt = W.sextdFromInt
val toIntX = W.schckToInt
fun toInt w =
Modified: mlton/branches/on-20050822-x86_64-branch/basis-library/mlton/word.sig
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library/mlton/word.sig 2007-03-14 01:37:13 UTC (rev 5425)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/mlton/word.sig 2007-03-14 02:24:42 UTC (rev 5426)
@@ -10,6 +10,7 @@
sig
type t
+ val bswap: t -> t
val rol: t * word -> t
val ror: t * word -> t
end
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 2007-03-14 01:37:13 UTC (rev 5425)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/primitive/basis-ffi.sml 2007-03-14 02:24:42 UTC (rev 5426)
@@ -227,42 +227,6 @@
val update = _import "PackReal64_update" : (Word8.t) array * C_Ptrdiff.t * Real64.t -> unit;
val updateRev = _import "PackReal64_updateRev" : (Word8.t) array * C_Ptrdiff.t * Real64.t -> unit;
end
-structure PackWord16 =
-struct
-val subArr = _import "PackWord16_subArr" : (Word8.t) array * C_Ptrdiff.t -> Word16.t;
-val subArrRev = _import "PackWord16_subArrRev" : (Word8.t) array * C_Ptrdiff.t -> Word16.t;
-val subVec = _import "PackWord16_subVec" : (Word8.t) vector * C_Ptrdiff.t -> Word16.t;
-val subVecRev = _import "PackWord16_subVecRev" : (Word8.t) vector * C_Ptrdiff.t -> Word16.t;
-val update = _import "PackWord16_update" : (Word8.t) array * C_Ptrdiff.t * Word16.t -> unit;
-val updateRev = _import "PackWord16_updateRev" : (Word8.t) array * C_Ptrdiff.t * Word16.t -> unit;
-end
-structure PackWord32 =
-struct
-val subArr = _import "PackWord32_subArr" : (Word8.t) array * C_Ptrdiff.t -> Word32.t;
-val subArrRev = _import "PackWord32_subArrRev" : (Word8.t) array * C_Ptrdiff.t -> Word32.t;
-val subVec = _import "PackWord32_subVec" : (Word8.t) vector * C_Ptrdiff.t -> Word32.t;
-val subVecRev = _import "PackWord32_subVecRev" : (Word8.t) vector * C_Ptrdiff.t -> Word32.t;
-val update = _import "PackWord32_update" : (Word8.t) array * C_Ptrdiff.t * Word32.t -> unit;
-val updateRev = _import "PackWord32_updateRev" : (Word8.t) array * C_Ptrdiff.t * Word32.t -> unit;
-end
-structure PackWord64 =
-struct
-val subArr = _import "PackWord64_subArr" : (Word8.t) array * C_Ptrdiff.t -> Word64.t;
-val subArrRev = _import "PackWord64_subArrRev" : (Word8.t) array * C_Ptrdiff.t -> Word64.t;
-val subVec = _import "PackWord64_subVec" : (Word8.t) vector * C_Ptrdiff.t -> Word64.t;
-val subVecRev = _import "PackWord64_subVecRev" : (Word8.t) vector * C_Ptrdiff.t -> Word64.t;
-val update = _import "PackWord64_update" : (Word8.t) array * C_Ptrdiff.t * Word64.t -> unit;
-val updateRev = _import "PackWord64_updateRev" : (Word8.t) array * C_Ptrdiff.t * Word64.t -> unit;
-end
-structure PackWord8 =
-struct
-val subArr = _import "PackWord8_subArr" : (Word8.t) array * C_Ptrdiff.t -> Word8.t;
-val subArrRev = _import "PackWord8_subArrRev" : (Word8.t) array * C_Ptrdiff.t -> Word8.t;
-val subVec = _import "PackWord8_subVec" : (Word8.t) vector * C_Ptrdiff.t -> Word8.t;
-val subVecRev = _import "PackWord8_subVecRev" : (Word8.t) vector * C_Ptrdiff.t -> Word8.t;
-val update = _import "PackWord8_update" : (Word8.t) array * C_Ptrdiff.t * Word8.t -> unit;
-val updateRev = _import "PackWord8_updateRev" : (Word8.t) array * C_Ptrdiff.t * Word8.t -> unit;
-end
structure Posix =
struct
structure Error =
Deleted: mlton/branches/on-20050822-x86_64-branch/basis-library/primitive/check-pack-word.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library/primitive/check-pack-word.sml 2007-03-14 01:37:13 UTC (rev 5425)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/primitive/check-pack-word.sml 2007-03-14 02:24:42 UTC (rev 5426)
@@ -1,61 +0,0 @@
-(* Copyright (C) 1999-2006 Henry Cejtin, Matthew Fluet, Suresh
- * Jagannathan, and Stephen Weeks.
- * Copyright (C) 1997-2000 NEC Research Institute.
- *
- * MLton is released under a BSD-style license.
- * See the file MLton-LICENSE for details.
- *)
-
-local
- fun 'a check (x: 'a, y: 'a) : unit = ()
-
- local
- structure PW1 = Primitive.PackWord8
- structure PW2 = PrimitiveFFI.PackWord8
- in
- val () = check (PW1.subArr, PW2.subArr)
- val () = check (PW1.subArrRev, PW2.subArrRev)
- val () = check (PW1.subVec, PW2.subVec)
- val () = check (PW1.subVecRev, PW2.subVecRev)
- val () = check (PW1.update, PW2.update)
- val () = check (PW1.updateRev, PW2.updateRev)
- end
-
- local
- structure PW1 = Primitive.PackWord16
- structure PW2 = PrimitiveFFI.PackWord16
- in
- val () = check (PW1.subArr, PW2.subArr)
- val () = check (PW1.subArrRev, PW2.subArrRev)
- val () = check (PW1.subVec, PW2.subVec)
- val () = check (PW1.subVecRev, PW2.subVecRev)
- val () = check (PW1.update, PW2.update)
- val () = check (PW1.updateRev, PW2.updateRev)
- end
-
- local
- structure PW1 = Primitive.PackWord32
- structure PW2 = PrimitiveFFI.PackWord32
- in
- val () = check (PW1.subArr, PW2.subArr)
- val () = check (PW1.subArrRev, PW2.subArrRev)
- val () = check (PW1.subVec, PW2.subVec)
- val () = check (PW1.subVecRev, PW2.subVecRev)
- val () = check (PW1.update, PW2.update)
- val () = check (PW1.updateRev, PW2.updateRev)
- end
-
- local
- structure PW1 = Primitive.PackWord64
- structure PW2 = PrimitiveFFI.PackWord64
- in
- val () = check (PW1.subArr, PW2.subArr)
- val () = check (PW1.subArrRev, PW2.subArrRev)
- val () = check (PW1.subVec, PW2.subVec)
- val () = check (PW1.subVecRev, PW2.subVecRev)
- val () = check (PW1.update, PW2.update)
- val () = check (PW1.updateRev, PW2.updateRev)
- end
-in
-
-end
Modified: mlton/branches/on-20050822-x86_64-branch/basis-library/primitive/primitive.mlb
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library/primitive/primitive.mlb 2007-03-14 01:37:13 UTC (rev 5425)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/primitive/primitive.mlb 2007-03-14 02:24:42 UTC (rev 5426)
@@ -72,6 +72,5 @@
(* Check compatibility between primitives and runtime functions. *)
check-real.sml
- check-pack-word.sml
check-pack-real.sml
end
Deleted: mlton/branches/on-20050822-x86_64-branch/runtime/basis/Word/PackWord.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/basis/Word/PackWord.c 2007-03-14 01:37:13 UTC (rev 5425)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/Word/PackWord.c 2007-03-14 02:24:42 UTC (rev 5426)
@@ -1,64 +0,0 @@
-#include "platform.h"
-
-#define Arr(t) Array(t)
-#define Vec(t) Vector(t)
-
-#define mkSubSeq(kind, Seq) \
-Word##kind##_t PackWord##kind##_sub##Seq (Seq(Word8_t) seq, C_Ptrdiff_t offset) { \
- Word##kind##_t w; \
- Word8_t* p = (Word8_t*)&w; \
- Word8_t* s = (Word8_t*)seq + offset; \
- int i; \
- \
- for (i = 0; i < kind / 8; ++i) \
- p[i] = s[i]; \
- return w; \
-}
-#define mkSubSeqRev(kind, Seq) \
-Word##kind##_t PackWord##kind##_sub##Seq##Rev (Seq(Word8_t) seq, C_Ptrdiff_t offset) { \
- Word##kind##_t w; \
- Word8_t* p = (Word8_t*)&w; \
- Word8_t* s = (Word8_t*)seq + offset; \
- int i; \
- \
- for (i = 0; i < kind / 8; ++i) \
- p[i] = s[((kind / 8) - 1) - i]; \
- return w; \
-}
-
-#define mkUpdate(kind) \
-void PackWord##kind##_update (Arr(Word8_t) a, C_Ptrdiff_t offset, Word##kind##_t w) { \
- Word8_t* p = (Word8_t*)&w; \
- Word8_t* s = (Word8_t*)a + offset; \
- int i; \
- \
- for (i = 0; i < kind / 8; ++i) \
- s[i] = p[i]; \
-}
-#define mkUpdateRev(kind) \
-void PackWord##kind##_updateRev (Arr(Word8_t) a, C_Ptrdiff_t offset, Word##kind##_t w) { \
- Word8_t* p = (Word8_t*)&w; \
- Word8_t* s = (Word8_t*)a + offset; \
- int i; \
- \
- for (i = 0; i < kind / 8; ++i) \
- s[i] = p[((kind / 8) - 1) - i]; \
-}
-
-#define all(size) \
- mkSubSeq(size, Arr) \
- mkSubSeq(size, Vec) \
- mkSubSeqRev(size, Arr) \
- mkSubSeqRev(size, Vec) \
- mkUpdate(size) \
- mkUpdateRev(size)
-
-all (8)
-all (16)
-all (32)
-all (64)
-
-#undef mkSubSeq
-#undef mkSubSeqRev
-#undef mkUpdate
-#undef all
Modified: mlton/branches/on-20050822-x86_64-branch/runtime/basis-ffi.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/basis-ffi.h 2007-03-14 01:37:13 UTC (rev 5425)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis-ffi.h 2007-03-14 02:24:42 UTC (rev 5426)
@@ -157,30 +157,6 @@
Real64_t PackReal64_subVecRev(Vector(Word8_t),C_Ptrdiff_t);
void PackReal64_update(Array(Word8_t),C_Ptrdiff_t,Real64_t);
void PackReal64_updateRev(Array(Word8_t),C_Ptrdiff_t,Real64_t);
-Word16_t PackWord16_subArr(Array(Word8_t),C_Ptrdiff_t);
-Word16_t PackWord16_subArrRev(Array(Word8_t),C_Ptrdiff_t);
-Word16_t PackWord16_subVec(Vector(Word8_t),C_Ptrdiff_t);
-Word16_t PackWord16_subVecRev(Vector(Word8_t),C_Ptrdiff_t);
-void PackWord16_update(Array(Word8_t),C_Ptrdiff_t,Word16_t);
-void PackWord16_updateRev(Array(Word8_t),C_Ptrdiff_t,Word16_t);
-Word32_t PackWord32_subArr(Array(Word8_t),C_Ptrdiff_t);
-Word32_t PackWord32_subArrRev(Array(Word8_t),C_Ptrdiff_t);
-Word32_t PackWord32_subVec(Vector(Word8_t),C_Ptrdiff_t);
-Word32_t PackWord32_subVecRev(Vector(Word8_t),C_Ptrdiff_t);
-void PackWord32_update(Array(Word8_t),C_Ptrdiff_t,Word32_t);
-void PackWord32_updateRev(Array(Word8_t),C_Ptrdiff_t,Word32_t);
-Word64_t PackWord64_subArr(Array(Word8_t),C_Ptrdiff_t);
-Word64_t PackWord64_subArrRev(Array(Word8_t),C_Ptrdiff_t);
-Word64_t PackWord64_subVec(Vector(Word8_t),C_Ptrdiff_t);
-Word64_t PackWord64_subVecRev(Vector(Word8_t),C_Ptrdiff_t);
-void PackWord64_update(Array(Word8_t),C_Ptrdiff_t,Word64_t);
-void PackWord64_updateRev(Array(Word8_t),C_Ptrdiff_t,Word64_t);
-Word8_t PackWord8_subArr(Array(Word8_t),C_Ptrdiff_t);
-Word8_t PackWord8_subArrRev(Array(Word8_t),C_Ptrdiff_t);
-Word8_t PackWord8_subVec(Vector(Word8_t),C_Ptrdiff_t);
-Word8_t PackWord8_subVecRev(Vector(Word8_t),C_Ptrdiff_t);
-void PackWord8_update(Array(Word8_t),C_Ptrdiff_t,Word8_t);
-void PackWord8_updateRev(Array(Word8_t),C_Ptrdiff_t,Word8_t);
void Posix_Error_clearErrno(void);
extern const C_Int_t Posix_Error_E2BIG;
extern const C_Int_t Posix_Error_EACCES;
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 2007-03-14 01:37:13 UTC (rev 5425)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gen/basis-ffi.def 2007-03-14 02:24:42 UTC (rev 5426)
@@ -150,30 +150,6 @@
PackReal64.subVecRev = _import : Word8.t vector * C_Ptrdiff.t -> Real64.t
PackReal64.update = _import : Word8.t array * C_Ptrdiff.t * Real64.t -> unit
PackReal64.updateRev = _import : Word8.t array * C_Ptrdiff.t * Real64.t -> unit
-PackWord8.subArr = _import : Word8.t array * C_Ptrdiff.t -> Word8.t
-PackWord8.subArrRev = _import : Word8.t array * C_Ptrdiff.t -> Word8.t
-PackWord8.subVec = _import : Word8.t vector * C_Ptrdiff.t -> Word8.t
-PackWord8.subVecRev = _import : Word8.t vector * C_Ptrdiff.t -> Word8.t
-PackWord8.update = _import : Word8.t array * C_Ptrdiff.t * Word8.t -> unit
-PackWord8.updateRev = _import : Word8.t array * C_Ptrdiff.t * Word8.t -> unit
-PackWord16.subArr = _import : Word8.t array * C_Ptrdiff.t -> Word16.t
-PackWord16.subArrRev = _import : Word8.t array * C_Ptrdiff.t -> Word16.t
-PackWord16.subVec = _import : Word8.t vector * C_Ptrdiff.t -> Word16.t
-PackWord16.subVecRev = _import : Word8.t vector * C_Ptrdiff.t -> Word16.t
-PackWord16.update = _import : Word8.t array * C_Ptrdiff.t * Word16.t -> unit
-PackWord16.updateRev = _import : Word8.t array * C_Ptrdiff.t * Word16.t -> unit
-PackWord32.subArr = _import : Word8.t array * C_Ptrdiff.t -> Word32.t
-PackWord32.subArrRev = _import : Word8.t array * C_Ptrdiff.t -> Word32.t
-PackWord32.subVec = _import : Word8.t vector * C_Ptrdiff.t -> Word32.t
-PackWord32.subVecRev = _import : Word8.t vector * C_Ptrdiff.t -> Word32.t
-PackWord32.update = _import : Word8.t array * C_Ptrdiff.t * Word32.t -> unit
-PackWord32.updateRev = _import : Word8.t array * C_Ptrdiff.t * Word32.t -> unit
-PackWord64.subArr = _import : Word8.t array * C_Ptrdiff.t -> Word64.t
-PackWord64.subArrRev = _import : Word8.t array * C_Ptrdiff.t -> Word64.t
-PackWord64.subVec = _import : Word8.t vector * C_Ptrdiff.t -> Word64.t
-PackWord64.subVecRev = _import : Word8.t vector * C_Ptrdiff.t -> Word64.t
-PackWord64.update = _import : Word8.t array * C_Ptrdiff.t * Word64.t -> unit
-PackWord64.updateRev = _import : Word8.t array * C_Ptrdiff.t * Word64.t -> unit
Posix.Error.E2BIG = _const : C_Int.t
Posix.Error.EACCES = _const : C_Int.t
Posix.Error.EADDRINUSE = _const : C_Int.t
Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gen/basis-ffi.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gen/basis-ffi.h 2007-03-14 01:37:13 UTC (rev 5425)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gen/basis-ffi.h 2007-03-14 02:24:42 UTC (rev 5426)
@@ -157,30 +157,6 @@
Real64_t PackReal64_subVecRev(Vector(Word8_t),C_Ptrdiff_t);
void PackReal64_update(Array(Word8_t),C_Ptrdiff_t,Real64_t);
void PackReal64_updateRev(Array(Word8_t),C_Ptrdiff_t,Real64_t);
-Word16_t PackWord16_subArr(Array(Word8_t),C_Ptrdiff_t);
-Word16_t PackWord16_subArrRev(Array(Word8_t),C_Ptrdiff_t);
-Word16_t PackWord16_subVec(Vector(Word8_t),C_Ptrdiff_t);
-Word16_t PackWord16_subVecRev(Vector(Word8_t),C_Ptrdiff_t);
-void PackWord16_update(Array(Word8_t),C_Ptrdiff_t,Word16_t);
-void PackWord16_updateRev(Array(Word8_t),C_Ptrdiff_t,Word16_t);
-Word32_t PackWord32_subArr(Array(Word8_t),C_Ptrdiff_t);
-Word32_t PackWord32_subArrRev(Array(Word8_t),C_Ptrdiff_t);
-Word32_t PackWord32_subVec(Vector(Word8_t),C_Ptrdiff_t);
-Word32_t PackWord32_subVecRev(Vector(Word8_t),C_Ptrdiff_t);
-void PackWord32_update(Array(Word8_t),C_Ptrdiff_t,Word32_t);
-void PackWord32_updateRev(Array(Word8_t),C_Ptrdiff_t,Word32_t);
-Word64_t PackWord64_subArr(Array(Word8_t),C_Ptrdiff_t);
-Word64_t PackWord64_subArrRev(Array(Word8_t),C_Ptrdiff_t);
-Word64_t PackWord64_subVec(Vector(Word8_t),C_Ptrdiff_t);
-Word64_t PackWord64_subVecRev(Vector(Word8_t),C_Ptrdiff_t);
-void PackWord64_update(Array(Word8_t),C_Ptrdiff_t,Word64_t);
-void PackWord64_updateRev(Array(Word8_t),C_Ptrdiff_t,Word64_t);
-Word8_t PackWord8_subArr(Array(Word8_t),C_Ptrdiff_t);
-Word8_t PackWord8_subArrRev(Array(Word8_t),C_Ptrdiff_t);
-Word8_t PackWord8_subVec(Vector(Word8_t),C_Ptrdiff_t);
-Word8_t PackWord8_subVecRev(Vector(Word8_t),C_Ptrdiff_t);
-void PackWord8_update(Array(Word8_t),C_Ptrdiff_t,Word8_t);
-void PackWord8_updateRev(Array(Word8_t),C_Ptrdiff_t,Word8_t);
void Posix_Error_clearErrno(void);
extern const C_Int_t Posix_Error_E2BIG;
extern const C_Int_t Posix_Error_EACCES;
Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gen/basis-ffi.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gen/basis-ffi.sml 2007-03-14 01:37:13 UTC (rev 5425)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gen/basis-ffi.sml 2007-03-14 02:24:42 UTC (rev 5426)
@@ -227,42 +227,6 @@
val update = _import "PackReal64_update" : (Word8.t) array * C_Ptrdiff.t * Real64.t -> unit;
val updateRev = _import "PackReal64_updateRev" : (Word8.t) array * C_Ptrdiff.t * Real64.t -> unit;
end
-structure PackWord16 =
-struct
-val subArr = _import "PackWord16_subArr" : (Word8.t) array * C_Ptrdiff.t -> Word16.t;
-val subArrRev = _import "PackWord16_subArrRev" : (Word8.t) array * C_Ptrdiff.t -> Word16.t;
-val subVec = _import "PackWord16_subVec" : (Word8.t) vector * C_Ptrdiff.t -> Word16.t;
-val subVecRev = _import "PackWord16_subVecRev" : (Word8.t) vector * C_Ptrdiff.t -> Word16.t;
-val update = _import "PackWord16_update" : (Word8.t) array * C_Ptrdiff.t * Word16.t -> unit;
-val updateRev = _import "PackWord16_updateRev" : (Word8.t) array * C_Ptrdiff.t * Word16.t -> unit;
-end
-structure PackWord32 =
-struct
-val subArr = _import "PackWord32_subArr" : (Word8.t) array * C_Ptrdiff.t -> Word32.t;
-val subArrRev = _import "PackWord32_subArrRev" : (Word8.t) array * C_Ptrdiff.t -> Word32.t;
-val subVec = _import "PackWord32_subVec" : (Word8.t) vector * C_Ptrdiff.t -> Word32.t;
-val subVecRev = _import "PackWord32_subVecRev" : (Word8.t) vector * C_Ptrdiff.t -> Word32.t;
-val update = _import "PackWord32_update" : (Word8.t) array * C_Ptrdiff.t * Word32.t -> unit;
-val updateRev = _import "PackWord32_updateRev" : (Word8.t) array * C_Ptrdiff.t * Word32.t -> unit;
-end
-structure PackWord64 =
-struct
-val subArr = _import "PackWord64_subArr" : (Word8.t) array * C_Ptrdiff.t -> Word64.t;
-val subArrRev = _import "PackWord64_subArrRev" : (Word8.t) array * C_Ptrdiff.t -> Word64.t;
-val subVec = _import "PackWord64_subVec" : (Word8.t) vector * C_Ptrdiff.t -> Word64.t;
-val subVecRev = _import "PackWord64_subVecRev" : (Word8.t) vector * C_Ptrdiff.t -> Word64.t;
-val update = _import "PackWord64_update" : (Word8.t) array * C_Ptrdiff.t * Word64.t -> unit;
-val updateRev = _import "PackWord64_updateRev" : (Word8.t) array * C_Ptrdiff.t * Word64.t -> unit;
-end
-structure PackWord8 =
-struct
-val subArr = _import "PackWord8_subArr" : (Word8.t) array * C_Ptrdiff.t -> Word8.t;
-val subArrRev = _import "PackWord8_subArrRev" : (Word8.t) array * C_Ptrdiff.t -> Word8.t;
-val subVec = _import "PackWord8_subVec" : (Word8.t) vector * C_Ptrdiff.t -> Word8.t;
-val subVecRev = _import "PackWord8_subVecRev" : (Word8.t) vector * C_Ptrdiff.t -> Word8.t;
-val update = _import "PackWord8_update" : (Word8.t) array * C_Ptrdiff.t * Word8.t -> unit;
-val updateRev = _import "PackWord8_updateRev" : (Word8.t) array * C_Ptrdiff.t * Word8.t -> unit;
-end
structure Posix =
struct
structure Error =
More information about the MLton-commit
mailing list