From 442f6e9049d9bc15fcee0bedbec6847723d75b65 Mon Sep 17 00:00:00 2001 From: Abdulaziz Ghuloum Date: Mon, 13 Oct 2008 02:40:26 -0400 Subject: [PATCH] - native bytevector operations on 16-bit values were implemented using the wrong endianness. --- scheme/ikarus.bytevectors.ss | 24 ++++++++++++------------ scheme/last-revision | 2 +- scheme/tests/pointers.ss | 18 +++++++++--------- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/scheme/ikarus.bytevectors.ss b/scheme/ikarus.bytevectors.ss index c8dd522..83f0dad 100644 --- a/scheme/ikarus.bytevectors.ss +++ b/scheme/ikarus.bytevectors.ss @@ -153,9 +153,9 @@ ($fx<= 0 i) ($fx< i ($fxsub1 ($bytevector-length x))) ($fxzero? ($fxlogand i 1))) - ($fxlogor - ($fxsll ($bytevector-u8-ref x i) 8) - ($bytevector-u8-ref x ($fxadd1 i))) + ($fxlogor ;;; little + ($bytevector-u8-ref x i) + ($fxsll ($bytevector-u8-ref x ($fxadd1 i)) 8)) (die 'bytevector-u16-native-ref "invalid index" i)) (die 'bytevector-u16-native-ref "not a bytevector" x)))) @@ -170,9 +170,9 @@ ($fx<= 0 i) ($fx< i ($fxsub1 ($bytevector-length x))) ($fxzero? ($fxlogand i 1))) - (begin - ($bytevector-set! x i ($fxsra n 8)) - ($bytevector-set! x ($fxadd1 i) n)) + (begin ;;; little + ($bytevector-set! x i n) + ($bytevector-set! x ($fxadd1 i) ($fxsra n 8))) (die 'bytevector-u16-native-set! "invalid index" i)) (die 'bytevector-u16-native-set! "invalid value" n)) (die 'bytevector-u16-native-set! "not a bytevector" x)))) @@ -187,9 +187,9 @@ ($fx<= 0 i) ($fx< i ($fxsub1 ($bytevector-length x))) ($fxzero? ($fxlogand i 1))) - (begin - ($bytevector-set! x i ($fxsra n 8)) - ($bytevector-set! x ($fxadd1 i) n)) + (begin ;;; little + ($bytevector-set! x i n) + ($bytevector-set! x ($fxadd1 i) ($fxsra n 8))) (die 'bytevector-s16-native-set! "invalid index" i)) (die 'bytevector-s16-native-set! "invalid value" n)) (die 'bytevector-s16-native-set! "not a bytevector" x)))) @@ -201,9 +201,9 @@ ($fx<= 0 i) ($fx< i ($fxsub1 ($bytevector-length x))) ($fxzero? ($fxlogand i 1))) - ($fxlogor - ($fxsll ($bytevector-s8-ref x i) 8) - ($bytevector-u8-ref x ($fxadd1 i))) + ($fxlogor ;;; little + ($bytevector-u8-ref x i) + ($fxsll ($bytevector-s8-ref x ($fxadd1 i)) 8)) (die 'bytevector-s16-native-ref "invalid index" i)) (die 'bytevector-s16-native-ref "not a bytevector" x)))) diff --git a/scheme/last-revision b/scheme/last-revision index dd3467d..6086cfb 100644 --- a/scheme/last-revision +++ b/scheme/last-revision @@ -1 +1 @@ -1623 +1624 diff --git a/scheme/tests/pointers.ss b/scheme/tests/pointers.ss index bade174..d3d2ef1 100644 --- a/scheme/tests/pointers.ss +++ b/scheme/tests/pointers.ss @@ -78,7 +78,7 @@ (combinations n))))) - (define (test-ref/set type combinations getter setter) + (define (t-ref/set type combinations getter setter) (printf "testing memory access (~s combination for type ~s)\n" (length combinations) type) @@ -115,14 +115,14 @@ (for-each check-combinations '(8 16 32 64)) (test-pointer-values) - (test-ref/set 'char (s* 8) pointer-ref-signed-char pointer-set-char) - (test-ref/set 'short (s* 16) pointer-ref-signed-short pointer-set-short) - (test-ref/set 'int (s* 32) pointer-ref-signed-int pointer-set-int) - (test-ref/set 'long (s* 64) pointer-ref-signed-long pointer-set-long) - (test-ref/set 'uchar (u* 8) pointer-ref-unsigned-char pointer-set-char) - (test-ref/set 'ushort (u* 16) pointer-ref-unsigned-short pointer-set-short) - (test-ref/set 'uint (u* 32) pointer-ref-unsigned-int pointer-set-int) - (test-ref/set 'ulong (u* 64) pointer-ref-unsigned-long pointer-set-long) + (t-ref/set 'char (s* 8) pointer-ref-c-signed-char pointer-set-c-char!) + (t-ref/set 'short (s* 16) pointer-ref-c-signed-short pointer-set-c-short!) + (t-ref/set 'int (s* 32) pointer-ref-c-signed-int pointer-set-c-int!) + (t-ref/set 'long (s* 64) pointer-ref-c-signed-long pointer-set-c-long!) + (t-ref/set 'uchar (u* 8) pointer-ref-c-unsigned-char pointer-set-c-char!) + (t-ref/set 'ushort (u* 16) pointer-ref-c-unsigned-short pointer-set-c-short!) + (t-ref/set 'uint (u* 32) pointer-ref-c-unsigned-int pointer-set-c-int!) + (t-ref/set 'ulong (u* 64) pointer-ref-c-unsigned-long pointer-set-c-long!) )