Merge jv
authorJan Vrany <jan.vrany@fit.cvut.cz>
Wed, 16 Mar 2016 08:51:12 +0000
branchjv
changeset 19408 8c80107973c7
parent 19407 2ef90564b9cc (current diff)
parent 19369 ccf33c1cd9d8 (diff)
child 19409 e6b872e766b4
Merge
ExternalLibraryFunction.st
UninterpretedBytes.st
Win32OperatingSystem.st
--- a/ExternalLibraryFunction.st	Wed Mar 16 08:50:14 2016 +0000
+++ b/ExternalLibraryFunction.st	Wed Mar 16 08:51:12 2016 +0000
@@ -891,7 +891,6 @@
      oldReturnType oldArgumentTypes|
 
     argTypeSymbols := argumentTypes.
-
     returnTypeSymbol := returnType.
     returnTypeSymbol isSymbol ifTrue:[ 
         | returnValueClass0 |
@@ -901,6 +900,7 @@
             returnValue := returnValueClass0 basicNew.
         ] 
     ].
+
     virtual := self isVirtualCPP.
     objectiveC := self isObjectiveC.
     (virtual "or:[self isNonVirtualCPP]") ifTrue:[
@@ -947,8 +947,6 @@
 #  ifndef HAS_LONGLONG
 #   define HAS_LONGLONG
 #  endif
-#  define __LO32(ll) ((ll) & 0xFFFFFFFFL)
-#  define __HI32(ll) (((ll)>>32) & 0xFFFFFFFFL)
 # endif
 # if defined(__BORLANDC__) || defined(__VISUALC__)
 #  define HAS_INT64
@@ -968,18 +966,10 @@
 	float fVal;
 	double dVal;
 	void *pointerVal;
-# if defined(HAS_LONGLONG)
+# if 0 && defined(HAS_LONGLONG)
 	long long longLongVal;
 # else
-#  ifdef HAS_INT64
 	__int64__ longLongVal;
-#  else
-	struct ll { long lo; long hi; } longLongVal;
-#   ifndef __LO32
-#    define __LO32(ll) (ll.lo)
-#    define __HI32(ll) (ll.hi)
-#   endif
-#  endif
 # endif
     };
     union u __argValuesIncludingThis[MAX_ARGS+1];
@@ -1409,29 +1399,7 @@
 	    }
 	    argValuePtr = &(__argValues[i].iVal);
 
-        } else if (typeSymbol == @symbol(uint64)) {
-            thisType = __get_ffi_type_uint64();
-            if (__isSmallInteger(arg)) {
-              __argValues[i].longLongVal = __intVal(arg);
-            } else {
-            	if (!__unsignedLong64IntVal(arg, &(__argValues[i].longLongVal))) {
-            	    __FAIL__(@symbol(InvalidArgument))
-            	}
-            }
-            argValuePtr = &(__argValues[i].longLongVal);
-            
-        } else if (typeSymbol == @symbol(sint64)) {
-            thisType = __get_ffi_type_sint64();
-            if (__isSmallInteger(arg)) {
-              __argValues[i].longLongVal = __intVal(arg);
-            } else {
-            	if (!__signedLong64IntVal(arg, &(__argValues[i].longLongVal))) {
-            	    __FAIL__(@symbol(InvalidArgument))
-            	}
-            }
-            argValuePtr = &(__argValues[i].longLongVal);
-            
-	} else if (typeSymbol == @symbol(float)) {
+        } else if (typeSymbol == @symbol(float)) {
 	    thisType = __get_ffi_type_float();
 	    if (__isSmallInteger(arg)) {
 		__argValues[i].fVal = (float)(__intVal(arg));
@@ -1891,6 +1859,7 @@
 	self primitiveFailed.   "see failureCode and failureInfo for details"
 	^ nil
     ].
+
     returnType isSymbol ifTrue:[
 	returnValueClass notNil ifTrue:[
 	    self isConstReturnValue ifTrue:[
--- a/UninterpretedBytes.st	Wed Mar 16 08:50:14 2016 +0000
+++ b/UninterpretedBytes.st	Wed Mar 16 08:51:12 2016 +0000
@@ -1,6 +1,6 @@
 "
  COPYRIGHT (c) 1993 by Claus Gittinger
-	      All Rights Reserved
+              All Rights Reserved
 
  This software is furnished under a license and may be used
  only in accordance with the terms of that license and with the
@@ -14,10 +14,10 @@
 "{ NameSpace: Smalltalk }"
 
 ArrayedCollection subclass:#UninterpretedBytes
-	instanceVariableNames:''
-	classVariableNames:'IsBigEndian'
-	poolDictionaries:''
-	category:'Collections-Abstract'
+        instanceVariableNames:''
+        classVariableNames:'IsBigEndian'
+        poolDictionaries:''
+        category:'Collections-Abstract'
 !
 
 !UninterpretedBytes primitiveDefinitions!
@@ -35,26 +35,26 @@
 #define __fetchBytePointerAndSize__(o, pPtr, pSize) \
     {\
       if (__isNonNilObject(o)) { \
-	if (__isByteArrayLike(o)) { \
-	  *(pPtr) = (unsigned char *)__ByteArrayInstPtr(o)->ba_element; \
-	  *(pSize) = __byteArraySize(o); \
-	} else if (__qIsExternalBytesLike(o)) { \
-	  OBJ __sz__ = __externalBytesSize(o); \
-	  if (__isSmallInteger(__sz__)) { \
-	    *(pSize) = __intVal(__sz__); \
-	    *(pPtr) = (unsigned char *)(__externalBytesAddress(o)); \
-	  } else { \
-	    *(pSize) = 0; \
-	    *(pPtr) = (unsigned char *)0; \
-	  } \
-	} else { \
-	    *(pSize) /* nInstBytes */ = OHDR_SIZE + __OBJS2BYTES__(__intVal(__ClassInstPtr(__qClass(o))->c_ninstvars)); \
-	    *(pPtr) = (char *)(__InstPtr(self)) + *(pSize) /* nInstBytes */; \
-	    *(pSize) = __qSize(self) - *(pSize) /* nInstBytes */; \
-	} \
+        if (__isByteArrayLike(o)) { \
+          *(pPtr) = (unsigned char *)__ByteArrayInstPtr(o)->ba_element; \
+          *(pSize) = __byteArraySize(o); \
+        } else if (__qIsExternalBytesLike(o)) { \
+          OBJ __sz__ = __externalBytesSize(o); \
+          if (__isSmallInteger(__sz__)) { \
+            *(pSize) = __intVal(__sz__); \
+            *(pPtr) = (unsigned char *)(__externalBytesAddress(o)); \
+          } else { \
+            *(pSize) = 0; \
+            *(pPtr) = (unsigned char *)0; \
+          } \
+        } else { \
+            *(pSize) /* nInstBytes */ = OHDR_SIZE + __OBJS2BYTES__(__intVal(__ClassInstPtr(__qClass(o))->c_ninstvars)); \
+            *(pPtr) = (char *)(__InstPtr(self)) + *(pSize) /* nInstBytes */; \
+            *(pSize) = __qSize(self) - *(pSize) /* nInstBytes */; \
+        } \
       } else { \
-	*(pSize) = 0; \
-	*(pPtr) = (unsigned char *)0; \
+        *(pSize) = 0; \
+        *(pPtr) = (unsigned char *)0; \
       } \
     }
 
@@ -66,7 +66,7 @@
 copyright
 "
  COPYRIGHT (c) 1993 by Claus Gittinger
-	      All Rights Reserved
+              All Rights Reserved
 
  This software is furnished under a license and may be used
  only in accordance with the terms of that license and with the
@@ -142,9 +142,9 @@
     bytes := self new: sz // 2.
     s := aString readStream.
     1 to: sz // 2 do: [ :idx |
-	hi := s next digitValue.
-	lo := s next digitValue.
-	bytes at:idx put: ((hi bitShift:4) bitOr: lo)
+        hi := s next digitValue.
+        lo := s next digitValue.
+        bytes at:idx put: ((hi bitShift:4) bitOr: lo)
     ].
     ^ bytes
 
@@ -159,7 +159,7 @@
     "
     "
      Time millisecondsToRun:[
-	1000000 timesRepeat:[ ByteArray fromHexString:'1234FEFF1234FEFF1234FEFF1234FEFF' ]
+        1000000 timesRepeat:[ ByteArray fromHexString:'1234FEFF1234FEFF1234FEFF1234FEFF' ]
      ].
     "
 
@@ -172,17 +172,17 @@
      See also fromHexString:, which does something similar, but does not allow for spaces"
 
     ^ self streamContents:[:outStream |
-	|inStream h|
-
-	inStream := aString readStream.
-
-	[
-	    inStream skipSeparators.
-	    inStream atEnd
-	] whileFalse:[
-	    h := inStream next:2.
-	    outStream nextPut:(Integer readFrom:h base:16).
-	].
+        |inStream h|
+
+        inStream := aString readStream.
+
+        [
+            inStream skipSeparators.
+            inStream atEnd
+        ] whileFalse:[
+            h := inStream next:2.
+            outStream nextPut:(Integer readFrom:h base:16).
+        ].
     ].
 
     "
@@ -222,47 +222,47 @@
 
     last := aString last codePoint.
     last > 96 ifTrue:[
-	stop := stop - 3 + (last - 96)
+        stop := stop - 3 + (last - 96)
     ].
     bytes := self new:stop.
 
     index := 1. dstIndex := 1.
     [dstIndex <= stop] whileTrue:[
-	"/ take 4 characters ...
-	"/ allow a line break before each group of 4
-	sixBits := (aString at:index) codePoint.
-	[sixBits < 32] whileTrue:[
-	    index := index + 1.
-	    sixBits := (aString at:index) codePoint.
-	].
-	sixBits := sixBits bitAnd:16r3F.
-	n := sixBits.
-
-	"/ self assert:(aString at:index+1) codePoint >= 32.
-	sixBits := (aString at:index+1) codePoint bitAnd:16r3F.
-	n := (n bitShift:6) + sixBits.
-
-	"/ self assert:(aString at:index+2) codePoint >= 32.
-	sixBits := (aString at:index+2) codePoint bitAnd:16r3F.
-	n := (n bitShift:6) + sixBits.
-
-	"/ self assert:(aString at:index+3) codePoint >= 32.
-	sixBits := (aString at:index+3) codePoint bitAnd:16r3F.
-	n := (n bitShift:6) + sixBits.
-
-	index := index + 4.
-
-	"/ now have 24 bits in n
-
-	bytes at:dstIndex put:(n bitShift:-16).
-
-	dstIndex < stop ifTrue:[
-	    bytes at:dstIndex+1 put:((n bitShift:-8) bitAnd:16rFF).
-	    dstIndex+2 <= stop ifTrue:[
-		bytes at:dstIndex+2 put:(n bitAnd:16rFF).
-	    ]
-	].
-	dstIndex := dstIndex + 3.
+        "/ take 4 characters ...
+        "/ allow a line break before each group of 4
+        sixBits := (aString at:index) codePoint.
+        [sixBits < 32] whileTrue:[
+            index := index + 1.
+            sixBits := (aString at:index) codePoint.
+        ].
+        sixBits := sixBits bitAnd:16r3F.
+        n := sixBits.
+
+        "/ self assert:(aString at:index+1) codePoint >= 32.
+        sixBits := (aString at:index+1) codePoint bitAnd:16r3F.
+        n := (n bitShift:6) + sixBits.
+
+        "/ self assert:(aString at:index+2) codePoint >= 32.
+        sixBits := (aString at:index+2) codePoint bitAnd:16r3F.
+        n := (n bitShift:6) + sixBits.
+
+        "/ self assert:(aString at:index+3) codePoint >= 32.
+        sixBits := (aString at:index+3) codePoint bitAnd:16r3F.
+        n := (n bitShift:6) + sixBits.
+
+        index := index + 4.
+
+        "/ now have 24 bits in n
+
+        bytes at:dstIndex put:(n bitShift:-16).
+
+        dstIndex < stop ifTrue:[
+            bytes at:dstIndex+1 put:((n bitShift:-8) bitAnd:16rFF).
+            dstIndex+2 <= stop ifTrue:[
+                bytes at:dstIndex+2 put:(n bitAnd:16rFF).
+            ]
+        ].
+        dstIndex := dstIndex + 3.
     ].
     ^ bytes
 
@@ -281,13 +281,13 @@
      ByteArray fromPackedString:((ByteArray new:64) asPackedString)
 
      0 to:256 do:[:l |
-	|orig copy|
-
-	0 to:255 do:[:fill |
-	    orig := ByteArray new:l withAll:fill.
-	    copy := ByteArray fromPackedString:(orig asPackedString).
-	    self assert:(orig = copy).
-	 ]
+        |orig copy|
+
+        0 to:255 do:[:fill |
+            orig := ByteArray new:l withAll:fill.
+            copy := ByteArray fromPackedString:(orig asPackedString).
+            self assert:(orig = copy).
+         ]
      ]
     "
 
@@ -314,72 +314,72 @@
     REGISTER OBJ *op;
 
     if (__isSmallInteger(anInteger)) {
-	nindexedinstvars = __intVal(anInteger);
-	if (nindexedinstvars >= 0) {
-	    if (self == ByteArray) {
-		/*
-		 * the most common case
-		 */
-		instsize = OHDR_SIZE + nindexedinstvars;
-		if (__CanDoQuickNew(instsize)) {        /* OBJECT ALLOCATION */
-		    __qCheckedNew(newobj, instsize);
-		    __InstPtr(newobj)->o_class = self;
-		    __qSTORE(newobj, self);
-		    RETURN (newobj );
-		}
-	    } else {
-		/*
-		 * Take care for subclasses like TwoByteString
-		 */
-		switch (__smallIntegerVal(__ClassInstPtr(self)->c_flags) & ARRAYMASK) {
-		case BYTEARRAY:
-		    break;
-
-		case WORDARRAY:
-		case SWORDARRAY:
-		    nindexedinstvars *= 2;
-		    break;
-
-		case LONGARRAY:
-		case SLONGARRAY:
-		    nindexedinstvars *= 4;
-		    break;
-
-		default:
-		    /* don't know about this array type, delegate to super */
-		    goto out;
-		}
-	    }
-	    nInstVars = __intVal(__ClassInstPtr(self)->c_ninstvars);
-	    instsize = OHDR_SIZE + __OBJS2BYTES__(nInstVars) + nindexedinstvars;
-	    __PROTECT_CONTEXT__
-	    __qNew(newobj, instsize);   /* OBJECT ALLOCATION */
-	    __UNPROTECT_CONTEXT__
-	    if (newobj != nil) {
-		__InstPtr(newobj)->o_class = self;
-		__qSTORE(newobj, self);
-		if (nInstVars) {
-		    /*
-		     * still have to nil out named instvars ...
-		     */
+        nindexedinstvars = __intVal(anInteger);
+        if (nindexedinstvars >= 0) {
+            if (self == ByteArray) {
+                /*
+                 * the most common case
+                 */
+                instsize = OHDR_SIZE + nindexedinstvars;
+                if (__CanDoQuickNew(instsize)) {        /* OBJECT ALLOCATION */
+                    __qCheckedNew(newobj, instsize);
+                    __InstPtr(newobj)->o_class = self;
+                    __qSTORE(newobj, self);
+                    RETURN (newobj );
+                }
+            } else {
+                /*
+                 * Take care for subclasses like TwoByteString
+                 */
+                switch (__smallIntegerVal(__ClassInstPtr(self)->c_flags) & ARRAYMASK) {
+                case BYTEARRAY:
+                    break;
+
+                case WORDARRAY:
+                case SWORDARRAY:
+                    nindexedinstvars *= 2;
+                    break;
+
+                case LONGARRAY:
+                case SLONGARRAY:
+                    nindexedinstvars *= 4;
+                    break;
+
+                default:
+                    /* don't know about this array type, delegate to super */
+                    goto out;
+                }
+            }
+            nInstVars = __intVal(__ClassInstPtr(self)->c_ninstvars);
+            instsize = OHDR_SIZE + __OBJS2BYTES__(nInstVars) + nindexedinstvars;
+            __PROTECT_CONTEXT__
+            __qNew(newobj, instsize);   /* OBJECT ALLOCATION */
+            __UNPROTECT_CONTEXT__
+            if (newobj != nil) {
+                __InstPtr(newobj)->o_class = self;
+                __qSTORE(newobj, self);
+                if (nInstVars) {
+                    /*
+                     * still have to nil out named instvars ...
+                     */
 #if defined(memset4) && defined(FAST_OBJECT_MEMSET4)
-		    memset4(__InstPtr(newobj)->i_instvars, nil, nInstVars);
+                    memset4(__InstPtr(newobj)->i_instvars, nil, nInstVars);
 #else
 # if defined(FAST_MEMSET) && !defined(NEGATIVE_ADDRESSES)
-		    /*
-		     * knowing that nil is 0
-		     */
-		    memset(__InstPtr(newobj)->i_instvars, 0, instsize - OHDR_SIZE);
+                    /*
+                     * knowing that nil is 0
+                     */
+                    memset(__InstPtr(newobj)->i_instvars, 0, instsize - OHDR_SIZE);
 # else
-		    op = __InstPtr(newobj)->i_instvars;
-		    while (nInstVars--)
-			*op++ = nil;
+                    op = __InstPtr(newobj)->i_instvars;
+                    while (nInstVars--)
+                        *op++ = nil;
 # endif
 #endif
-		}
-		RETURN ( newobj );
-	    }
-	}
+                }
+                RETURN ( newobj );
+            }
+        }
     }
 out:;
 %}.
@@ -418,7 +418,7 @@
      I.e. false for vax, intel; true for m68k, sun.
 
      Notice: UninterpretedBytes isBigEndian
-	     this is inlined both by stc and the jit compiler"
+             this is inlined both by stc and the jit compiler"
 
 %{  /* NOCONTEXT */
 
@@ -439,8 +439,8 @@
      *    constant for systems where this is known.
      */
     union {
-	unsigned int   u_l;
-	char           u_c[sizeof(int)];
+        unsigned int   u_l;
+        char           u_c[sizeof(int)];
     } u;
 
     u.u_l = 0x87654321;
@@ -467,6 +467,7 @@
     "Modified: / 5.3.1998 / 14:56:22 / stefan"
 ! !
 
+
 !UninterpretedBytes methodsFor:'Compatibility'!
 
 doubleWordAt:index
@@ -839,7 +840,7 @@
      This may be worth a primitive.
      This is the ST80 equivalent of #signedWordAt:"
 
-    ^ (self unsignedInt16At:index MSB:IsBigEndian) signExtendedShortValue
+    ^ self signedInt16At:index MSB:IsBigEndian
 
     "
      |b|
@@ -860,7 +861,7 @@
      LSB-first otherwise.
      This is the ST80 equivalent of #signedWordAt:"
 
-    ^ (self unsignedInt16At:index MSB:msb) signExtendedShortValue
+    ^ self signedInt16At:index MSB:msb
 
     "
      |b|
@@ -1724,7 +1725,7 @@
      (i.e. the value n is encoded as: ((n // 10) * 16) + (n \\ 10)"
 
     (aNumber between:0 and:99) ifFalse:[
-	self error:'invalid value for BCD encoding'
+        self error:'invalid value for BCD encoding'
     ].
     ^ self byteAt:index put:aNumber encodeAsBCD
 
@@ -2479,41 +2480,41 @@
 
 %{
     if (__isSmallInteger(index)) {
-	unsigned char *cp;
-	INT sz;
-
-	__fetchBytePointerAndSize__(self, &cp, &sz);
-	if (cp) {
-	    unsigned INT idx = ((unsigned INT)__smallIntegerVal(index)) - 1;
-	    char *pointer;
-
-	    if ((idx+(sizeof(pointer)-1)) < sz) {
-		cp += idx;
-		/*
-		 * aligned
-		 */
-		if (((INT)cp & (sizeof(pointer)-1)) == 0) {
-		    pointer = ((char **)cp)[0];
-		    RETURN (__MKEXTERNALADDRESS(pointer));
-		} else {
+        unsigned char *cp;
+        INT sz;
+
+        __fetchBytePointerAndSize__(self, &cp, &sz);
+        if (cp) {
+            unsigned INT idx = ((unsigned INT)__smallIntegerVal(index)) - 1;
+            char *pointer;
+
+            if ((idx+(sizeof(pointer)-1)) < sz) {
+                cp += idx;
+                /*
+                 * aligned
+                 */
+                if (((INT)cp & (sizeof(pointer)-1)) == 0) {
+                    pointer = ((char **)cp)[0];
+                    RETURN (__MKEXTERNALADDRESS(pointer));
+                } else {
 #if 0
-		    printf("cp UNALIGNED (%"_lx_")\n", (INT)cp);
+                    printf("cp UNALIGNED (%"_lx_")\n", (INT)cp);
 #endif
-		}
-	    } else {
+                }
+            } else {
 #if 0
-		printf("idx(%"_ld_")+(sizeof(pointer)-1) (%d) >= sz (%"_ld_")\n",
-			idx, (int)(sizeof(pointer)-1), sz);
+                printf("idx(%"_ld_")+(sizeof(pointer)-1) (%d) >= sz (%"_ld_")\n",
+                        idx, (int)(sizeof(pointer)-1), sz);
 #endif
-	    }
-	} else {
+            }
+        } else {
 #if 0
-	    printf("cp is NULL\n");
+            printf("cp is NULL\n");
 #endif
-	}
+        }
     } else {
 #if 0
-	printf("bad index\n");
+        printf("bad index\n");
 #endif
     }
 bad:;
@@ -2540,40 +2541,40 @@
     OBJ *pointer;
 
     if (__isExternalAddressLike(value)) {
-	pointer = __externalAddressVal(value);
+        pointer = __externalAddressVal(value);
     } else if (__isExternalBytesLike(value)) {
-	pointer = __externalBytesVal(value);
-	if (pointer == (OBJ *)0)
-	    pointer = 0;
+        pointer = __externalBytesVal(value);
+        if (pointer == (OBJ *)0)
+            pointer = 0;
     } else if (value == nil) {
-	pointer = 0;
+        pointer = 0;
     } else if (__isSmallInteger(value)) {
-	pointer = (OBJ *)__intVal(value);
+        pointer = (OBJ *)__intVal(value);
     } else {
-	if ((pointer = (OBJ *)__unsignedLongIntVal(value)) == 0) {
-	    goto bad;
-	}
+        if ((pointer = (OBJ *)__unsignedLongIntVal(value)) == 0) {
+            goto bad;
+        }
     }
 
     if (__isSmallInteger(index)) {
-	unsigned char *cp;
-	INT sz;
-
-	__fetchBytePointerAndSize__(self, &cp, &sz);
-	if (cp) {
-	    unsigned INT idx = ((unsigned INT)__smallIntegerVal(index)) - 1;
-
-	    if ((idx+(sizeof(pointer)-1)) < sz) {
-		cp += idx;
-		/*
-		 * aligned
-		 */
-		if (((INT)cp & (sizeof(pointer)-1)) == 0) {
-		    ((char **)cp)[0] = (char *) pointer;
-		    RETURN (value);
-		}
-	    }
-	}
+        unsigned char *cp;
+        INT sz;
+
+        __fetchBytePointerAndSize__(self, &cp, &sz);
+        if (cp) {
+            unsigned INT idx = ((unsigned INT)__smallIntegerVal(index)) - 1;
+
+            if ((idx+(sizeof(pointer)-1)) < sz) {
+                cp += idx;
+                /*
+                 * aligned
+                 */
+                if (((INT)cp & (sizeof(pointer)-1)) == 0) {
+                    ((char **)cp)[0] = (char *) pointer;
+                    RETURN (value);
+                }
+            }
+        }
     }
 bad:;
 %}.
@@ -3156,19 +3157,55 @@
 signedInt16At:byteIndex MSB:msb
     "return the 2-bytes starting at index as a signed Integer.
      The index is a smalltalk index (i.e. 1-based).
-     The value is retrieved in the machines natural byte order.
-     This may be worth a primitive."
-
-    ^ (self unsignedInt16At:byteIndex MSB:msb) signExtendedShortValue
-
-    "
-     |b|
-     b := ByteArray new:2.
-     b wordAt:1 put:16rFFFF.
-     b signedWordAt:1
-    "
-
-    "Modified: 1.7.1996 / 21:14:38 / cg"
+     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 it's false.
+     Notice: 
+        the index is a byte index; thus, this allows for unaligned access to
+        words on any boundary."
+
+    |b1 "{ Class: SmallInteger }"
+     b2 "{ Class: SmallInteger }"|
+
+%{
+    /*
+     * handle the most common cases fast ...
+     */
+    if (__isSmallInteger(byteIndex)) {
+        unsigned char *cp;
+        INT sz;
+
+        __fetchBytePointerAndSize__(self, &cp, &sz);
+        if (cp) {
+            unsigned INT idx = ((unsigned INT)__intVal(byteIndex)) - 1;
+
+            if ((idx+(2-1)) < sz) {
+                short sVal;
+
+                cp += idx;
+                if (msb == false) {
+#if defined(__i386__) || (defined(__LSBFIRST__) && defined(UNALIGNED_FETCH_OK))
+                    /*
+                     * aligned or not, we dont care (i386 can do both)
+                     */
+                    sVal = ((short *)cp)[0];
+#else
+                    sVal = (cp[0] & 0xFF) | ((cp[1] & 0xFF) << 8);
+#endif
+                } else {
+                    sVal = ((cp[0] & 0xFF) << 8) | (cp[1] & 0xFF);
+                }
+                RETURN (__mkSmallInteger(sVal));
+            }
+        }
+    }
+%}.
+
+    b1 := self byteAt:byteIndex.
+    b2 := self byteAt:(byteIndex + 1).
+    msb ifTrue:[
+        ^ ((b1 bitShift:8) + b2) signExtendedShortValue
+    ].
+    ^ ((b2 bitShift:8) + b1) signExtendedShortValue
 !
 
 signedInt16At:index put:anInteger
@@ -3190,29 +3227,64 @@
     "Modified: 1.7.1996 / 21:12:13 / cg"
 !
 
-signedInt16At:index put:anInteger MSB:msb
-    "set the 2-bytes starting at index from the signed Integer value.
-     The index is a smalltalk index (i.e. 1-based).
+signedInt16At:byteIndex put:anInteger MSB:msb
+    "set the 2-bytes starting at byteIndex from the signed integer value.
+     The byteIndex is a smalltalk index (i.e. 1-based).
      The stored value must be in the range -32768 .. +32676.
      The value is stored MSB-first, if the msb-arg is true;
-     LSB-first otherwise.
-     This may be worth a primitive."
-
-    |v|
-
+     LSB-first otherwise."
+
+%{  /* NOCONTEXT */
+    /*
+     * handle the most common case fast ...
+     */
+    if (__isSmallInteger(byteIndex)) {
+        unsigned char *cp;
+        INT sz;
+
+        __fetchBytePointerAndSize__(self, &cp, &sz);
+        if (cp) {
+            unsigned INT idx = ((unsigned INT)__intVal(byteIndex)) - 1;
+
+            if ((idx+1) < sz) {
+                cp += idx;
+
+                if (__isSmallInteger(anInteger)) {
+                    INT __v = __intVal(anInteger);
+
+                    if ((__v < -0x8000L) || (__v > 0x7FFF)) {
+                        goto badArg;
+                    }
+                    if (msb == false) { 
+#if defined(__i386__) || (defined(__LSBFIRST__) && defined(UNALIGNED_FETCH_OK))
+                        ((short *)cp)[0] = (short)__v;
+#else
+                        cp[0] = __v & 0xFF;
+                        cp[1] = (__v >> 8) & 0xFF;
+#endif
+                    } else {        
+                        cp[0] = (__v >> 8) & 0xFF;
+                        cp[1] = __v & 0xFF;
+                    }
+                    RETURN (anInteger);
+                }
+            }
+        }
+    }
+  badArg: ;
+%}.
     anInteger >= 0 ifTrue:[
-        v := anInteger
+        self unsignedInt16At:byteIndex put:anInteger MSB:msb.
     ] ifFalse:[
-        v := 16r10000 + anInteger
+        self unsignedInt16At:byteIndex put:(16r10000 + anInteger) MSB:msb.
     ].
-    self unsignedInt16At:index put:v MSB:msb.
     ^ anInteger
 
     "
      |b|
      b := ByteArray new:4.
-     b signedWordAt:1 put:-1.
-     b signedWordAt:3 put:-2.
+     b signedInt16At:1 put:-1.
+     b signedInt16At:3 put:-2.
      b inspect
     "
 
@@ -3228,11 +3300,11 @@
     ^ self unsignedInt16At:index MSB:IsBigEndian
 !
 
-unsignedInt16At:index MSB:msb
+unsignedInt16At:byteIndex 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.
+     LSB-first (i.e. low 8-bits at lower byte index) if it's false.
      Notice: 
         the index is a byte index; thus, this allows for unaligned access to
         words on any boundary."
@@ -3240,8 +3312,42 @@
     |b1 "{ Class: SmallInteger }"
      b2 "{ Class: SmallInteger }"|
 
-    b1 := self byteAt:index.
-    b2 := self byteAt:(index + 1).
+%{
+    /*
+     * handle the most common cases fast ...
+     */
+    if (__isSmallInteger(byteIndex)) {
+        unsigned char *cp;
+        INT sz;
+
+        __fetchBytePointerAndSize__(self, &cp, &sz);
+        if (cp) {
+            unsigned INT idx = ((unsigned INT)__intVal(byteIndex)) - 1;
+
+            if ((idx+(2-1)) < sz) {
+                int iVal;
+
+                cp += idx;
+                if (msb == false) {
+#if defined(__i386__) || (defined(__LSBFIRST__) && defined(UNALIGNED_FETCH_OK))
+                    /*
+                     * aligned or not, we dont care (i386 can do both)
+                     */
+                    iVal = ((unsigned short *)cp)[0];
+#else
+                    iVal = (cp[0] & 0xFF) | ((cp[1] & 0xFF) << 8);
+#endif
+                } else {
+                    iVal = ((cp[0] & 0xFF) << 8) | (cp[1] & 0xFF);
+                }
+                RETURN (__mkSmallInteger(iVal));
+            }
+        }
+    }
+%}.
+
+    b1 := self byteAt:byteIndex.
+    b2 := self byteAt:(byteIndex + 1).
     msb ifTrue:[
         ^ (b1 bitShift:8) + b2
     ].
@@ -3268,7 +3374,7 @@
     "Modified: / 5.3.1998 / 14:59:38 / stefan"
 !
 
-unsignedInt16At:index put:anInteger MSB:msb
+unsignedInt16At:byteIndex put:anInteger MSB:msb
     "set the 2-bytes starting at index from the (unsigned) Integer value.
      The index is a smalltalk index (i.e. 1-based).
      The stored value must be in the range 0 .. 16rFFFF.
@@ -3278,6 +3384,46 @@
     |b1 b2
      iVal "{ Class: SmallInteger }"|
 
+%{  /* NOCONTEXT */
+    /*
+     * handle the most common case fast ...
+     */
+    if (__isSmallInteger(byteIndex)) {
+        unsigned char *cp;
+        INT sz;
+
+        __fetchBytePointerAndSize__(self, &cp, &sz);
+printf("cp=%"_lx_"\n", (INT)cp);
+        if (cp) {
+            unsigned INT idx = ((unsigned INT)__intVal(byteIndex)) - 1;
+
+            if ((idx+1) < sz) {
+                cp += idx;
+
+                if (__isSmallInteger(anInteger)) {
+                    INT __v = __intVal(anInteger);
+
+                    if (((unsigned INT)__v) > 0xFFFF) {
+                        goto badArg;
+                    }
+                    if (msb == false) { 
+#if defined(__i386__) || (defined(__LSBFIRST__) && defined(UNALIGNED_FETCH_OK))
+                        ((unsigned short *)cp)[0] = (unsigned short)__v;
+#else
+                        cp[0] = __v & 0xFF;
+                        cp[1] = (__v >> 8) & 0xFF;
+#endif
+                    } else {        
+                        cp[0] = (__v >> 8) & 0xFF;
+                        cp[1] = __v & 0xFF;
+                    }
+                    RETURN (anInteger);
+                }
+            }
+        }
+    }
+  badArg: ;
+%}.
     iVal := anInteger.
     ((iVal < 0) or:[iVal > 16rFFFF]) ifTrue:[
         ^ self elementBoundsError:iVal
@@ -3289,17 +3435,17 @@
         b1 := (iVal bitAnd:16rFF).
         b2 := ((iVal bitShift:-8) bitAnd:16rFF).
     ].
-    self byteAt:index   put:b1.
-    self byteAt:index+1 put:b2.
+    self byteAt:byteIndex   put:b1.
+    self byteAt:byteIndex+1 put:b2.
     ^ anInteger
 
     "
      |b|
      b := ByteArray new:8.
-     b unsignedShortAt:1 put:16r0102 bigEndian:false.
-     b unsignedShortAt:3 put:16r0304 bigEndian:false.
-     b unsignedShortAt:5 put:16r0102 bigEndian:true.
-     b unsignedShortAt:7 put:16r0304 bigEndian:true.
+     b unsignedInt16At:1 put:16r0102 MSB:false.
+     b unsignedInt16At:3 put:16r0304 MSB:false.
+     b unsignedInt16At:5 put:16r0102 MSB:true.
+     b unsignedInt16At:7 put:16r0304 MSB:true.
      b inspect
     "
 
@@ -3318,8 +3464,8 @@
     stream := WriteStream on:(String new:40).
     i := index.
     [(c := self byteAt:i) ~~ 0] whileTrue:[
-	stream nextPut:(Character value:c).
-	i := i + 1.
+        stream nextPut:(Character value:c).
+        i := i + 1.
     ].
     ^ stream contents
 
@@ -3424,11 +3570,11 @@
     max := start + maxSize - 1.
 
     start to:max do:[:eachIndex|
-	c := self byteAt:eachIndex.
-	c == 0 ifTrue:[
-	    ^ stream contents
-	].
-	stream nextPut:(Character value:c).
+        c := self byteAt:eachIndex.
+        c == 0 ifTrue:[
+            ^ stream contents
+        ].
+        stream nextPut:(Character value:c).
     ].
     ^ stream contents
 
@@ -3531,8 +3677,8 @@
     cls := self class.
 
     (cls == ByteArray or:[cls == ImmutableByteArray or:[cls == ExternalBytes]]) ifTrue:[
-	size := self size.
-	^ (String uninitializedNew:size) replaceBytesFrom:1 to:size with:self startingAt:1.
+        size := self size.
+        ^ (String uninitializedNew:size) replaceBytesFrom:1 to:size with:self startingAt:1.
     ].
     ^ super asString.
 
@@ -3568,12 +3714,12 @@
       |utf8Encoding original readBack|
 
       1 to:16rFFFF do:[:ascii |
-	original := (Character value:ascii) asString.
-	utf8Encoding := original utf8Encoded.
-	readBack := utf8Encoding utf8Decoded.
-	readBack = original ifFalse:[
-	    self halt
-	]
+        original := (Character value:ascii) asString.
+        utf8Encoding := original utf8Encoded.
+        readBack := utf8Encoding utf8Decoded.
+        readBack = original ifFalse:[
+            self halt
+        ]
       ]
     "
 !
@@ -3586,26 +3732,26 @@
     |in out c|
 
     self containsNon7BitAscii ifFalse:[
-	^ self asSingleByteString
+        ^ self asSingleByteString
     ].
 
     out := WriteStream on:(String uninitializedNew:self size * 3 // 2).
     in := self readStream.
     [in atEnd] whileFalse:[
-	c := Character utf8DecodeFrom:in.
-	c codePoint > 16rFF ifTrue:[
-	    c := replacementCharacter
-	].
-	out nextPut:c.
+        c := Character utf8DecodeFrom:in.
+        c codePoint > 16rFF ifTrue:[
+            c := replacementCharacter
+        ].
+        out nextPut:c.
     ].
     ^ out contents
 
     "
      (Character value:16r220) utf8Encoded
-	utf8DecodedWithTwoByteCharactersReplacedBy:(Character space)
+        utf8DecodedWithTwoByteCharactersReplacedBy:(Character space)
 
      (Character value:16r220) utf8Encoded asExternalBytes copyButLast
-	utf8DecodedWithTwoByteCharactersReplacedBy:(Character space)
+        utf8DecodedWithTwoByteCharactersReplacedBy:(Character space)
     "
 ! !
 
@@ -3633,142 +3779,142 @@
      && (__isBytes(self) || __isWords(self))
      && __bothSmallInteger(start, stop)
      && __isSmallInteger(repStart)) {
-	startIndex = __intVal(start) - 1;
-	if (startIndex >= 0) {
-	    dst = (__ByteArrayInstPtr(self)->ba_element) + startIndex;
-	    nIndex = __byteArraySize(self);
-
-	    if ((cls = __qClass(self)) != @global(ByteArray)) {
-		int nInst;
-
-		nInst = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
-		dst += nInst;
-		nIndex -= nInst;
-	    }
-
-	    stopIndex = __intVal(stop) - 1;
-	    count = stopIndex - startIndex + 1;
-	    if (count == 0) {
-		RETURN ( self );
-	    }
-
-	    if ((count > 0) && (stopIndex < nIndex)) {
-		repStartIndex = __intVal(repStart) - 1;
-		if (repStartIndex >= 0) {
-		    if (__isExternalBytesLike(aCollection)) {
-			OBJ sz;
-
-			src = __externalAddressVal(aCollection);
-			if (src == 0) goto fallBack;
-
-			sz = __externalBytesSize(aCollection);
-			if (__isSmallInteger(sz)) {
-			    repNIndex = __smallIntegerVal(sz);
-			} else {
-			    repNIndex = repStopIndex+1; /* always enough */
-			}
-			src = src + repStartIndex;
-		    } else {
-			if (__isStringLike(aCollection)) {
-			    repNIndex = __stringSize(aCollection);
-			} else {
-			    repNIndex = __qSize(aCollection) - OHDR_SIZE;
-			}
-			src = (__ByteArrayInstPtr(aCollection)->ba_element) + repStartIndex;
-			if ((cls = __qClass(aCollection)) != @global(ByteArray)) {
-			    int nInst;
-
-			    nInst = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
-			    src += nInst;
-			    repNIndex -= nInst;
-			}
-		    }
-		    repStopIndex = repStartIndex + (stopIndex - startIndex);
-		    if (repStopIndex < repNIndex) {
-			if (aCollection == self) {
-			    /* take care of overlapping copy */
-			    if (src < dst) {
-				/* must do a reverse copy */
-				src += count;
-				dst += count;
-				while (count-- > 0) {
-				    *--dst = *--src;
-				}
-				RETURN ( self );
-			    }
-			}
+        startIndex = __intVal(start) - 1;
+        if (startIndex >= 0) {
+            dst = (__ByteArrayInstPtr(self)->ba_element) + startIndex;
+            nIndex = __byteArraySize(self);
+
+            if ((cls = __qClass(self)) != @global(ByteArray)) {
+                int nInst;
+
+                nInst = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
+                dst += nInst;
+                nIndex -= nInst;
+            }
+
+            stopIndex = __intVal(stop) - 1;
+            count = stopIndex - startIndex + 1;
+            if (count == 0) {
+                RETURN ( self );
+            }
+
+            if ((count > 0) && (stopIndex < nIndex)) {
+                repStartIndex = __intVal(repStart) - 1;
+                if (repStartIndex >= 0) {
+                    if (__isExternalBytesLike(aCollection)) {
+                        OBJ sz;
+
+                        src = __externalAddressVal(aCollection);
+                        if (src == 0) goto fallBack;
+
+                        sz = __externalBytesSize(aCollection);
+                        if (__isSmallInteger(sz)) {
+                            repNIndex = __smallIntegerVal(sz);
+                        } else {
+                            repNIndex = repStopIndex+1; /* always enough */
+                        }
+                        src = src + repStartIndex;
+                    } else {
+                        if (__isStringLike(aCollection)) {
+                            repNIndex = __stringSize(aCollection);
+                        } else {
+                            repNIndex = __qSize(aCollection) - OHDR_SIZE;
+                        }
+                        src = (__ByteArrayInstPtr(aCollection)->ba_element) + repStartIndex;
+                        if ((cls = __qClass(aCollection)) != @global(ByteArray)) {
+                            int nInst;
+
+                            nInst = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
+                            src += nInst;
+                            repNIndex -= nInst;
+                        }
+                    }
+                    repStopIndex = repStartIndex + (stopIndex - startIndex);
+                    if (repStopIndex < repNIndex) {
+                        if (aCollection == self) {
+                            /* take care of overlapping copy */
+                            if (src < dst) {
+                                /* must do a reverse copy */
+                                src += count;
+                                dst += count;
+                                while (count-- > 0) {
+                                    *--dst = *--src;
+                                }
+                                RETURN ( self );
+                            }
+                        }
 
 # ifdef bcopy4
-			if (((unsigned INT)src & 3) == ((unsigned INT)dst & 3)) {
-			    int nW;
-
-			    /* copy unaligned part */
-			    while (count && ((unsigned INT)src & 3)) {
-				*dst++ = *src++;
-				count--;
-			    }
-
-			    if (count > 0) {
-				/* copy aligned part */
-				nW = count >> 2;
-				bcopy4(src, dst, nW);
-				if ((count = count & 3) != 0) {
-				    /* copy any remaining part */
-				    src += (nW<<2);
-				    dst += (nW<<2);
-				    while (count--) {
-					*dst++ = *src++;
-				    }
-				}
-			    }
-			    RETURN ( self );
-			}
+                        if (((unsigned INT)src & 3) == ((unsigned INT)dst & 3)) {
+                            int nW;
+
+                            /* copy unaligned part */
+                            while (count && ((unsigned INT)src & 3)) {
+                                *dst++ = *src++;
+                                count--;
+                            }
+
+                            if (count > 0) {
+                                /* copy aligned part */
+                                nW = count >> 2;
+                                bcopy4(src, dst, nW);
+                                if ((count = count & 3) != 0) {
+                                    /* copy any remaining part */
+                                    src += (nW<<2);
+                                    dst += (nW<<2);
+                                    while (count--) {
+                                        *dst++ = *src++;
+                                    }
+                                }
+                            }
+                            RETURN ( self );
+                        }
 # else
 #  if __POINTER_SIZE__ == 8
-			if (((unsigned INT)src & 7) == ((unsigned INT)dst & 7)) {
-			    /* copy unaligned part */
-			    while (count && ((unsigned INT)src & 7)) {
-				*dst++ = *src++;
-				count--;
-			    }
-
-			    /* copy aligned part */
-			    while (count >= 8) {
-				((unsigned INT *)dst)[0] = ((unsigned INT *)src)[0];
-				dst += 8;
-				src += 8;
-				count -= 8;
-			    }
-			    while (count--) {
-				*dst++ = *src++;
-			    }
-			    RETURN ( self );
-			}
+                        if (((unsigned INT)src & 7) == ((unsigned INT)dst & 7)) {
+                            /* copy unaligned part */
+                            while (count && ((unsigned INT)src & 7)) {
+                                *dst++ = *src++;
+                                count--;
+                            }
+
+                            /* copy aligned part */
+                            while (count >= 8) {
+                                ((unsigned INT *)dst)[0] = ((unsigned INT *)src)[0];
+                                dst += 8;
+                                src += 8;
+                                count -= 8;
+                            }
+                            while (count--) {
+                                *dst++ = *src++;
+                            }
+                            RETURN ( self );
+                        }
 #  endif /* 64bit */
 # endif /* bcopy4 */
 
 # ifdef FAST_MEMCPY
-			bcopy(src, dst, count);
+                        bcopy(src, dst, count);
 # else
 #  ifdef __UNROLL_LOOPS__
-			while (count >= 8) {
-			    dst[0] = src[0]; dst[1] = src[1];
-			    dst[2] = src[2]; dst[3] = src[3];
-			    dst[4] = src[4]; dst[5] = src[5];
-			    dst[6] = src[6]; dst[7] = src[7];
-			    dst += 8; src += 8;
-			    count -= 8;
-			}
+                        while (count >= 8) {
+                            dst[0] = src[0]; dst[1] = src[1];
+                            dst[2] = src[2]; dst[3] = src[3];
+                            dst[4] = src[4]; dst[5] = src[5];
+                            dst[6] = src[6]; dst[7] = src[7];
+                            dst += 8; src += 8;
+                            count -= 8;
+                        }
 #  endif /* __UNROLL_LOOPS__ */
-			while (count-- > 0) {
-			    *dst++ = *src++;
-			}
+                        while (count-- > 0) {
+                            *dst++ = *src++;
+                        }
 # endif
-			RETURN ( self );
-		    }
-		}
-	    }
-	}
+                        RETURN ( self );
+                    }
+                }
+            }
+        }
     }
 fallBack: ;
 #endif
@@ -3781,34 +3927,34 @@
 
     "
      #[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16]
-	copy
-	    replaceFrom:1 to:8
-	    with:#[10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160]
-	    startingAt:1
+        copy
+            replaceFrom:1 to:8
+            with:#[10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160]
+            startingAt:1
 
      #[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16]
-	copy
-	    replaceFrom:3 to:10
-	    with:#[10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160]
-	    startingAt:1
+        copy
+            replaceFrom:3 to:10
+            with:#[10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160]
+            startingAt:1
 
      #[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16]
-	copy
-	    replaceFrom:3 to:4
-	    with:#[10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160]
-	    startingAt:1
+        copy
+            replaceFrom:3 to:4
+            with:#[10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160]
+            startingAt:1
 
      #[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16]
-	copy
-	    replaceFrom:0 to:9
-	    with:#[10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160]
-	    startingAt:1
+        copy
+            replaceFrom:0 to:9
+            with:#[10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160]
+            startingAt:1
 
      #[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16]
-	copy
-	    replaceFrom:1 to:10
-	    with:#[10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160]
-	    startingAt:0
+        copy
+            replaceFrom:1 to:10
+            with:#[10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160]
+            startingAt:0
     "
 !
 
@@ -3820,15 +3966,15 @@
      therefore the change may affect all others referencing the receiver."
 
     ^ self
-	replaceBytesFrom:startIndex
-	to:(startIndex + replacementCollection size - repStartIndex)
-	with:replacementCollection
-	startingAt:repStartIndex
+        replaceBytesFrom:startIndex
+        to:(startIndex + replacementCollection size - repStartIndex)
+        with:replacementCollection
+        startingAt:repStartIndex
 
     "
      args:    startIndex            : <integer>
-	      replacementCollection : <collection of <bytes> >
-	      repStartIndex         : <integer>
+              replacementCollection : <collection of <bytes> >
+              repStartIndex         : <integer>
 
      returns: self
     "
@@ -3845,10 +3991,10 @@
      therefore the change may affect all others referencing the receiver."
 
     ^ self
-	replaceBytesFrom:1
-	to:(replacementCollection size min:self size)
-	with:replacementCollection
-	startingAt:1
+        replaceBytesFrom:1
+        to:(replacementCollection size min:self size)
+        with:replacementCollection
+        startingAt:1
 
     "
      (ByteArray new:10) replaceBytesWith:'hello'
@@ -3867,18 +4013,18 @@
      therefore the change may affect all others referencing the receiver."
 
     self class isBytes ifTrue:[
-	((aCollection class == self class)
-	 or:[aCollection isByteCollection]) ifTrue:[
-	    ^ self replaceBytesFrom:startIndex to:stopIndex with:aCollection startingAt:repStartIndex
-	].
+        ((aCollection class == self class)
+         or:[aCollection isByteCollection]) ifTrue:[
+            ^ self replaceBytesFrom:startIndex to:stopIndex with:aCollection startingAt:repStartIndex
+        ].
     ].
     ^ super replaceFrom:startIndex to:stopIndex with:aCollection startingAt:repStartIndex
 
     "
      args:    startIndex            : <integer>
-	      stopIndex             : <integer>
-	      replacementCollection : <collection of <bytes> >
-	      repStartIndex         : <integer>
+              stopIndex             : <integer>
+              replacementCollection : <collection of <bytes> >
+              repStartIndex         : <integer>
 
      returns: self
     "
@@ -3894,94 +4040,94 @@
      If endindex = 0 or endIndex > size, hash up the size.
 
      NOTE: startIndex and endIndex are only hints about what should be hashed.
-	   In fact, more bytes could be involved in hashing.
-	   SO ARRAYS MUST BE EQUAL TO HASH TO THE SAME VALUE"
+           In fact, more bytes could be involved in hashing.
+           SO ARRAYS MUST BE EQUAL TO HASH TO THE SAME VALUE"
 
     |w|
 
 %{
     if (__bothSmallInteger(startIndex, endIndex)) {
-	unsigned char *cp;
-	INT sz;
-
-	__fetchBytePointerAndSize__(self, &cp, &sz);
-	if (cp) {
-	    INT sidx = ((unsigned INT)__smallIntegerVal(startIndex)) - 1;
-	    INT eidx = ((unsigned INT)__smallIntegerVal(endIndex)) - 1;
-	    unsigned char *ep;
-	    unsigned INT hash = 0, hash2 = 0, carry;
-	    int i;
-
-	    if (eidx < 0 || eidx >= sz) eidx = sz - 1;
-	    if (sidx > eidx) sidx = eidx;
-	    if (sidx < 0) {
-		RETURN(__mkSmallInteger(0));
-	    }
-
-	    ep = cp + eidx;
-	    cp += sidx;
+        unsigned char *cp;
+        INT sz;
+
+        __fetchBytePointerAndSize__(self, &cp, &sz);
+        if (cp) {
+            INT sidx = ((unsigned INT)__smallIntegerVal(startIndex)) - 1;
+            INT eidx = ((unsigned INT)__smallIntegerVal(endIndex)) - 1;
+            unsigned char *ep;
+            unsigned INT hash = 0, hash2 = 0, carry;
+            int i;
+
+            if (eidx < 0 || eidx >= sz) eidx = sz - 1;
+            if (sidx > eidx) sidx = eidx;
+            if (sidx < 0) {
+                RETURN(__mkSmallInteger(0));
+            }
+
+            ep = cp + eidx;
+            cp += sidx;
 
 #if 0
-	    /*
-	     * On LSB-First (little endian) cpus,
-	     * this code does not produce the same result
-	     * if the same bytes are at different positions
-	     */
-
-	    if ((INT)cp & (sizeof(INT)-1)) {
-		/* not aligned */
-
-		for (i=0; cp <= ep; cp++) {
-		    hash2 = (hash2 << 8) | *cp;
-		    if (++i == sizeof(INT)) {
-			hash ^= hash2;
-			i = hash2 = 0;
-		    }
-		}
-	    } else {
-		/* aligned */
-		for (; cp+sizeof(INT) <= ep; cp += sizeof(INT)) {
-		    hash ^= *(unsigned INT *)cp;
-		}
-		for (; cp <= ep; cp++) {
-		    hash2 = (hash2 << 8) | *cp;
-		}
-	    }
+            /*
+             * On LSB-First (little endian) cpus,
+             * this code does not produce the same result
+             * if the same bytes are at different positions
+             */
+
+            if ((INT)cp & (sizeof(INT)-1)) {
+                /* not aligned */
+
+                for (i=0; cp <= ep; cp++) {
+                    hash2 = (hash2 << 8) | *cp;
+                    if (++i == sizeof(INT)) {
+                        hash ^= hash2;
+                        i = hash2 = 0;
+                    }
+                }
+            } else {
+                /* aligned */
+                for (; cp+sizeof(INT) <= ep; cp += sizeof(INT)) {
+                    hash ^= *(unsigned INT *)cp;
+                }
+                for (; cp <= ep; cp++) {
+                    hash2 = (hash2 << 8) | *cp;
+                }
+            }
 #else
-	    for (i=0; cp <= ep-sizeof(INT); cp += sizeof(INT)) {
-		hash2 = cp[0];
-		hash2 = (hash2 << 8) | cp[1];
-		hash2 = (hash2 << 8) | cp[2];
-		hash2 = (hash2 << 8) | cp[3];
+            for (i=0; cp <= ep-sizeof(INT); cp += sizeof(INT)) {
+                hash2 = cp[0];
+                hash2 = (hash2 << 8) | cp[1];
+                hash2 = (hash2 << 8) | cp[2];
+                hash2 = (hash2 << 8) | cp[3];
 #if __POINTER_SIZE__ == 8
-		hash2 = (hash2 << 8) | cp[4];
-		hash2 = (hash2 << 8) | cp[5];
-		hash2 = (hash2 << 8) | cp[6];
-		hash2 = (hash2 << 8) | cp[7];
+                hash2 = (hash2 << 8) | cp[4];
+                hash2 = (hash2 << 8) | cp[5];
+                hash2 = (hash2 << 8) | cp[6];
+                hash2 = (hash2 << 8) | cp[7];
 #endif
-		/*
-		 * multiply by large prime to scramble bits and
-		 * to avoid a 0 result from
-		 * #[1 2 3 4 1 2 3 4] computeXorHashFrom:1 to:8.
-		 */
-		hash ^= (hash * 31415821) ^ hash2;
-	    }
-	    for (hash2 = 0; cp <= ep; cp++) {
-		hash2 = (hash2 << 8) | *cp;
-	    }
+                /*
+                 * multiply by large prime to scramble bits and
+                 * to avoid a 0 result from
+                 * #[1 2 3 4 1 2 3 4] computeXorHashFrom:1 to:8.
+                 */
+                hash ^= (hash * 31415821) ^ hash2;
+            }
+            for (hash2 = 0; cp <= ep; cp++) {
+                hash2 = (hash2 << 8) | *cp;
+            }
 #endif
-	    hash ^= (hash * 31415821) ^ hash2;
-
-	    /*
-	     * fold the high bits not fitting into a SmallInteger
-	     */
-	    carry = hash & ~_MAX_INT;
-	    if (carry) {
-		hash = (hash & _MAX_INT) ^ (carry >> 8);
-	    }
-
-	    RETURN(__mkSmallInteger(hash));
-	}
+            hash ^= (hash * 31415821) ^ hash2;
+
+            /*
+             * fold the high bits not fitting into a SmallInteger
+             */
+            carry = hash & ~_MAX_INT;
+            if (carry) {
+                hash = (hash & _MAX_INT) ^ (carry >> 8);
+            }
+
+            RETURN(__mkSmallInteger(hash));
+        }
     }
 %}.
 
@@ -4056,14 +4202,14 @@
 
     first := true.
     1 to:self size do:[:idx |
-	aSeparatorStringOrCharacterOrNil notNil ifTrue:[
-	    first ifFalse:[
-		aSeparatorStringOrCharacterOrNil printOn:aStream
-	    ] ifTrue:[
-		first := false.
-	    ].
-	].
-	(self byteAt:idx) printOn:aStream base:16 size:2 fill:$0.
+        aSeparatorStringOrCharacterOrNil notNil ifTrue:[
+            first ifFalse:[
+                aSeparatorStringOrCharacterOrNil printOn:aStream
+            ] ifTrue:[
+                first := false.
+            ].
+        ].
+        (self byteAt:idx) printOn:aStream base:16 size:2 fill:$0.
     ].
 
     "
@@ -4092,9 +4238,9 @@
     "print as hex string, eg: 'FF:02:43'."
 
     ^ String
-	streamContents:[:s |
-	    self hexPrintOn:s withSeparator:aSeparatorStringOrCharacterOrNil.
-	]
+        streamContents:[:s |
+            self hexPrintOn:s withSeparator:aSeparatorStringOrCharacterOrNil.
+        ]
 
     "
       #[1 2 3 4 10 17] hexPrintStringWithSeparator:$:
@@ -4163,14 +4309,14 @@
 
 %{ /* NOCONTEXT */
     if (__mkSmallInteger(0) == __ClassInstPtr(__qClass(self))->c_ninstvars) {
-	/* I am only bytes */
-	RETURN(false)
+        /* I am only bytes */
+        RETURN(false)
     }
 %}.
     ^ super referencesAny:aCollection
 
     "
-	'abc' referencesAny:#()
+        'abc' referencesAny:#()
     "
 !
 
--- a/Win32OperatingSystem.st	Wed Mar 16 08:50:14 2016 +0000
+++ b/Win32OperatingSystem.st	Wed Mar 16 08:51:12 2016 +0000
@@ -12015,31 +12015,31 @@
 !
 
 collate
-    ^ self shortAt: 1+68
+    ^ self signedInt16At: 1+68 MSB: UninterpretedBytes isBigEndian
 
     "Created: / 01-08-2006 / 09:56:38 / fm"
 !
 
 collate: n
-    ^ self shortAt: 1+68 put: n
+    ^ self signedInt16At: 1+68 put: n MSB: UninterpretedBytes isBigEndian
 
     "Created: / 01-08-2006 / 09:58:07 / fm"
 !
 
 color
-    ^ self shortAt: 1+60
+    ^ self signedInt16At: 1+60 MSB: UninterpretedBytes isBigEndian
 
     "Created: / 27-07-2006 / 15:31:25 / fm"
 !
 
 copies
-    ^ self shortAt: 1+54
+    ^ self signedInt16At: 1+54 MSB: UninterpretedBytes isBigEndian
 
     "Created: / 27-07-2006 / 15:30:52 / fm"
 !
 
 copies: n
-    ^ self shortAt: 1+54 put: n
+    ^ self signedInt16At: 1+54 put: n MSB: UninterpretedBytes isBigEndian
 
     "Created: / 27-07-2006 / 15:36:39 / fm"
 !
@@ -12051,61 +12051,61 @@
 !
 
 orientation
-    ^ self shortAt: 1+44
+    ^ self signedInt16At: 1+44 MSB: UninterpretedBytes isBigEndian
 
     "Created: / 27-07-2006 / 15:34:57 / fm"
 !
 
 orientation: orientationInt
-    ^ self shortAt: 1+44 put: orientationInt
+    ^ self signedInt16At: 1+44 put: orientationInt MSB: UninterpretedBytes isBigEndian
 
     "Created: / 27-07-2006 / 15:36:31 / fm"
 !
 
 paperLength
-    ^ self shortAt: 1+48
+    ^ self signedInt16At: 1+48 MSB: UninterpretedBytes isBigEndian
 
     "Created: / 27-07-2006 / 15:32:59 / fm"
 !
 
 paperSize
-    ^ self shortAt: 1+46
+    ^ self signedInt16At: 1+46 MSB: UninterpretedBytes isBigEndian
 
     "Created: / 27-07-2006 / 15:32:12 / fm"
 !
 
 paperSize:funnyMSPaperSizeCode
-    ^ self shortAt: 1+46 put: funnyMSPaperSizeCode
+    ^ self signedInt16At: 1+46 put: funnyMSPaperSizeCode MSB: UninterpretedBytes isBigEndian
 
     "Created: / 27-07-2006 / 15:35:53 / fm"
 !
 
 paperWidth
-    ^ self shortAt: 1+50
+    ^ self signedInt16At: 1+50 MSB: UninterpretedBytes isBigEndian
 
     "Created: / 27-07-2006 / 15:32:25 / fm"
 !
 
 printQuality
-    ^ self shortAt: 1+58
+    ^ self signedInt16At: 1+58 MSB: UninterpretedBytes isBigEndian
 
     "Created: / 27-07-2006 / 15:33:58 / fm"
 !
 
 printQuality: qualityInteger
-    ^ self shortAt: 1+58 put: qualityInteger
+    ^ self signedInt16At: 1+58 put: qualityInteger MSB: UninterpretedBytes isBigEndian
 
     "Created: / 27-07-2006 / 15:36:20 / fm"
 !
 
 scale
-    ^ self shortAt: 1+52
+    ^ self signedInt16At: 1+52 MSB: UninterpretedBytes isBigEndian
 
     "Created: / 27-07-2006 / 15:33:31 / fm"
 !
 
 scale: percent
-    ^ self shortAt: 1+52 put: percent
+    ^ self signedInt16At: 1+52 put: percent MSB: UninterpretedBytes isBigEndian
 
     "Created: / 27-07-2006 / 15:36:05 / fm"
 ! !
@@ -12853,7 +12853,7 @@
 !Win32OperatingSystem::PECOFFFileHeader methodsFor:'accessing'!
 
 machine
-   ^ data wordAt: COFF_HEADER_Machine_OFFSET + 1 MSB: false
+   ^ data unsignedInt16At: COFF_HEADER_Machine_OFFSET + 1 MSB: false
 
     "Created: / 16-03-2015 / 14:29:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !