Merge jv
authorJan Vrany <jan.vrany@fit.cvut.cz>
Sat, 23 Jan 2016 07:26:00 +0000
branchjv
changeset 3716 be22b8b2f524
parent 3706 0db6c0586c81 (current diff)
parent 3709 b24c7442ce72 (diff)
child 3717 fa068792624e
Merge
BackgroundQueueProcessingJob.st
--- a/BackgroundQueueProcessingJob.st	Tue Jan 19 07:00:28 2016 +0000
+++ b/BackgroundQueueProcessingJob.st	Sat Jan 23 07:26:00 2016 +0000
@@ -140,8 +140,6 @@
 !
 
 add: object at: index
-    "includes: is not synchronized, but should not harm"
-
     queueAccessLock critical:[
         (queue includes: object) ifFalse:[
             index notNil ifTrue:[
--- a/IntegerArray.st	Tue Jan 19 07:00:28 2016 +0000
+++ b/IntegerArray.st	Sat Jan 23 07:26:00 2016 +0000
@@ -11,6 +11,8 @@
 "
 "{ Package: 'stx:libbasic2' }"
 
+"{ NameSpace: Smalltalk }"
+
 UnboxedIntegerArray variableLongSubclass:#IntegerArray
 	instanceVariableNames:''
 	classVariableNames:''
@@ -65,6 +67,44 @@
     "Created: / 15-09-2011 / 14:12:15 / cg"
 ! !
 
+!IntegerArray methodsFor:'accessing'!
+
+doubleWordAt:index MSB:msb
+    "return the 4-bytes starting at index as an (unsigned) Integer.
+     The index is a smalltalk index (i.e. 1-based).
+     The value is retrieved MSB (high 8 bits at lower index) if msb is true;
+     LSB-first (i.e. low 8-bits at lower byte index) if its false.
+     Notice: 
+        the index is a byte index; thus, this allows for unaligned access to
+        words on any boundary.
+     Question: should it be retrieve signed values ? (see ByteArray>>signedWordAt:)"
+
+    |w|
+
+    (index bitAnd: 16r03) == 1 ifTrue:[
+        "/ aligned fetch
+        w := self at:(index // 4) + 1.
+        (msb ~~ UninterpretedBytes isBigEndian) ifTrue:[
+            w := w swapBytes
+        ].    
+        ^ w
+    ].
+    ^ super doubleWordAt:index MSB:msb
+
+    "
+     #(16r0201 16r0403 16r0605) asIntegerArray doubleWordAt:1 MSB:false
+     #(16r0201 16r0403 16r0605) asIntegerArray doubleWordAt:5 MSB:false
+     #(16r0201 16r0403 16r0605) asIntegerArray doubleWordAt:9 MSB:false
+
+     #(16r0201 16r0403 16r0605) asIntegerArray doubleWordAt:2 MSB:false
+     #(16r0201 16r0403 16r0605) asIntegerArray doubleWordAt:3 MSB:false
+     #(16r0201 16r0403 16r0605) asIntegerArray doubleWordAt:4 MSB:false
+
+     #(16rFFEE 16r0403 16r0605) asIntegerArray doubleWordAt:1 MSB:false
+     #(16rFFEE 16r0403 16r0605) asIntegerArray doubleWordAt:1 MSB:true
+    "
+! !
+
 !IntegerArray methodsFor:'comparing'!
 
 < anIntegerArray
@@ -155,10 +195,10 @@
 !IntegerArray class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic2/IntegerArray.st,v 1.7 2014-09-23 20:15:39 cg Exp $'
+    ^ '$Header$'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic2/IntegerArray.st,v 1.7 2014-09-23 20:15:39 cg Exp $'
+    ^ '$Header$'
 ! !
 
--- a/WordArray.st	Tue Jan 19 07:00:28 2016 +0000
+++ b/WordArray.st	Sat Jan 23 07:26:00 2016 +0000
@@ -11,6 +11,8 @@
 "
 "{ Package: 'stx:libbasic2' }"
 
+"{ NameSpace: Smalltalk }"
+
 UnboxedIntegerArray variableWordSubclass:#WordArray
 	instanceVariableNames:''
 	classVariableNames:''
@@ -63,8 +65,6 @@
 "
 ! !
 
-
-
 !WordArray class methodsFor:'queries'!
 
 elementByteSize
@@ -76,10 +76,46 @@
     "Created: / 15-09-2011 / 14:10:54 / cg"
 ! !
 
+!WordArray methodsFor:'accessing'!
+
+wordAt:index MSB:msb
+    "return the 2-bytes starting at index as an (unsigned) Integer.
+     The index is a smalltalk index (i.e. 1-based).
+     The value is retrieved MSB (high 8 bits at lower index) if msb is true;
+     LSB-first (i.e. low 8-bits at lower byte index) if its false.
+     Notice: 
+        the index is a byte index; thus, this allows for unaligned access to
+        words on any boundary.
+     Question: should it be retrieve signed values ? (see ByteArray>>signedWordAt:)"
+
+    |w|
+    
+    index odd ifTrue:[
+        "/ aligned fetch
+        w := self at:(index // 2) + 1.
+        (msb ~~ UninterpretedBytes isBigEndian) ifTrue:[
+            w := w swapBytes
+        ].    
+        ^ w
+    ].
+    ^ super wordAt:index MSB:msb
+
+    "
+     #(16r0201 16r0403 16r0605) asWordArray wordAt:1 MSB:false
+     #(16r0201 16r0403 16r0605) asWordArray wordAt:3 MSB:false
+     #(16r0201 16r0403 16r0605) asWordArray wordAt:5 MSB:false
+
+     #(16r0201 16r0403 16r0605) asWordArray wordAt:2 MSB:false
+     #(16r0201 16r0403 16r0605) asWordArray wordAt:4 MSB:false
+
+     #(16rFFEE 16r0403 16r0605) asWordArray wordAt:1 MSB:false
+     #(16rFFEE 16r0403 16r0605) asWordArray wordAt:1 MSB:true
+    "
+! !
 
 !WordArray class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic2/WordArray.st,v 1.9 2014-09-23 20:14:52 cg Exp $'
+    ^ '$Header$'
 ! !