ExternalBytes.st
branchjv
changeset 18011 deb0c3355881
parent 17940 985e22966acb
parent 14632 6fe0dc1d5377
child 18026 fa8a879502cb
--- a/ExternalBytes.st	Thu Dec 20 11:48:59 2012 +0000
+++ b/ExternalBytes.st	Sat Jan 19 01:30:00 2013 +0000
@@ -56,7 +56,7 @@
 	    }
 	}
 	if (! found) {
-	    console_printf("ExternalBytes [warning]: **** free: alien %lx (allocated somewhere else ?))\n", (long)ptr);
+	    console_printf("ExternalBytes [warning]: **** free: alien %"_lx_" (allocated somewhere else ?))\n", (INT)ptr);
 	}
     }
 }
@@ -75,7 +75,7 @@
 	found = 0;
 	for (this=mallocList; this; this=this->next) {
 	    if (this->chunk == ptr) {
-		console_printf("ExternalBytes [warning]: **** %016lx already allocated (freed somewhere else ?)\n", (long)ptr);
+		console_printf("ExternalBytes [warning]: **** %016"_lx_" already allocated (freed somewhere else ?)\n", (INT)ptr);
 		found++;
 	    }
 	}
@@ -98,7 +98,7 @@
 	ptr = malloc(nBytes);
 
 	if (@global(TraceMalloc) == true) {
-	    console_printf("ExternalBytes [info]: allocated %d bytes at: %016lx\n", nBytes, (long)ptr);
+	    console_printf("ExternalBytes [info]: allocated %d bytes at: %016"_lx_"\n", nBytes, (INT)ptr);
 	}
 
 	addToMallocList(ptr, nBytes);
@@ -129,7 +129,7 @@
 	addToMallocList(newPtr, nBytes);
 
 	if (@global(TraceMalloc) == true) {
-	    console_printf("ExternalBytes [info]: realloc %d bytes for %016lx at: %016lx\n", nBytes, (long)ptr, (long)newPtr);
+	    console_printf("ExternalBytes [info]: realloc %d bytes for %016"_lx_" at: %016"_lx_"\n", nBytes, (INT)ptr, (INT)newPtr);
 	}
 	return newPtr;
 }
@@ -483,7 +483,7 @@
     struct mallocList *entry;
 
     for (entry = mallocList; entry; entry=entry->next) {
-	console_printf("  %lx (%d)\n", (long)entry->chunk, entry->size);
+	console_printf("  %"_lx_" (%d)\n", (INT)(entry->chunk), entry->size);
     }
 %}
     "
@@ -509,7 +509,7 @@
 
     while ((entry = mallocList) != (struct mallocList *)0) {
 	if (@global(TraceMalloc) == true ) {
-	    console_printf("ExternalBytes [info]: **** forced free of %lx (%d)\n", (long)entry->chunk, entry->size);
+	    console_printf("ExternalBytes [info]: **** forced free of %"_lx_" (%d)\n", (INT)entry->chunk, entry->size);
 	}
 	__stx_free(entry->chunk);
     }
@@ -816,131 +816,131 @@
     if ((__isBytes(aCollection) || __isWords(aCollection) || __isExternalBytesLike(aCollection))
      && __bothSmallInteger(start, stop)
      && __isSmallInteger(repStart)) {
-        startIndex = __intVal(start) - 1;
-        if (startIndex >= 0) {
-            dst = (unsigned char *)__INST(address_) + startIndex;
-            nIndex = __smallIntegerVal(__INST(size));
+	startIndex = __intVal(start) - 1;
+	if (startIndex >= 0) {
+	    dst = (unsigned char *)__INST(address_) + startIndex;
+	    nIndex = __smallIntegerVal(__INST(size));
 
-            stopIndex = __intVal(stop) - 1;
-            count = stopIndex - startIndex + 1;
-            if (count == 0) {
-                RETURN ( self );
-            }
+	    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;
+	    if ((count > 0) && (stopIndex < nIndex)) {
+		repStartIndex = __intVal(repStart) - 1;
+		if (repStartIndex >= 0) {
+		    if (__isExternalBytesLike(aCollection)) {
+			OBJ sz;
 
-                        src = __externalBytesVal(aCollection);
-                        if (src == 0) goto fallBack;
+			src = __externalBytesVal(aCollection);
+			if (src == 0) goto fallBack;
 
-                        sz = __externalBytesSize(aCollection);
-                        if (__isSmallInteger(sz)) {
-                            repNIndex = __smallIntegerVal(sz);
-                        } else {
-                            repNIndex = -1; /* unknown */
-                        }
-                        src = src + repStartIndex;
-                    } else {
-                        repNIndex = __qSize(aCollection) - OHDR_SIZE;
-                        src = __byteArrayVal(aCollection) + repStartIndex;
-                        if ((cls = __qClass(aCollection)) != @global(ByteArray)) {
-                            int nInst;
+			sz = __externalBytesSize(aCollection);
+			if (__isSmallInteger(sz)) {
+			    repNIndex = __smallIntegerVal(sz);
+			} else {
+			    repNIndex = -1; /* unknown */
+			}
+			src = src + repStartIndex;
+		    } else {
+			repNIndex = __qSize(aCollection) - OHDR_SIZE;
+			src = __byteArrayVal(aCollection) + repStartIndex;
+			if ((cls = __qClass(aCollection)) != @global(ByteArray)) {
+			    int nInst;
 
-                            nInst = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
-                            src += nInst;
-                            repNIndex -= 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 );
-                            }
-                        }
+		    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 memcpy4
-                        if (((unsigned INT)src & 3) == ((unsigned INT)dst & 3)) {
-                            int nW;
+			if (((unsigned INT)src & 3) == ((unsigned INT)dst & 3)) {
+			    int nW;
 
-                            /* copy unaligned part */
-                            while (count && ((unsigned INT)src & 3)) {
-                                *dst++ = *src++;
-                                count--;
-                            }
+			    /* copy unaligned part */
+			    while (count && ((unsigned INT)src & 3)) {
+				*dst++ = *src++;
+				count--;
+			    }
 
-                            if (count > 0) {
-                                /* copy aligned part */
-                                nW = count >> 2;
-                                memcpy4(dst, src, nW);
-                                if ((count = count & 3) != 0) {
-                                    /* copy any remaining part */
-                                    src += (nW<<2);
-                                    dst += (nW<<2);
-                                    while (count--) {
-                                        *dst++ = *src++;
-                                    }
-                                }
-                            }
-                            RETURN ( self );
-                        }
+			    if (count > 0) {
+				/* copy aligned part */
+				nW = count >> 2;
+				memcpy4(dst, src, 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--;
-                            }
+			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 );
-                        }
+			    /* 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 /* memcpy4 */
 
 #ifdef FAST_MEMCPY
-                        memcpy(dst, src, count);
+			memcpy(dst, src, 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: ;
 %}.
@@ -951,29 +951,29 @@
 
     "
      ((ExternalBytes unprotectedNew:16)
-            replaceBytesFrom:1 to:8
-            with:#[10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160]
-            startingAt:1) copy
+	    replaceBytesFrom:1 to:8
+	    with:#[10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160]
+	    startingAt:1) copy
 
      (ExternalBytes unprotectedNew:16)
-            replaceBytesFrom:3 to:10
-            with:#[10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160]
-            startingAt:4
+	    replaceBytesFrom:3 to:10
+	    with:#[10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160]
+	    startingAt:4
 
      (ExternalBytes unprotectedNew:16)
-            replaceBytesFrom:3 to:4
-            with:#[10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160]
-            startingAt:1
+	    replaceBytesFrom:3 to:4
+	    with:#[10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160]
+	    startingAt:1
 
      (ExternalBytes unprotectedNew:16)
-            replaceBytesFrom:0 to:9
-            with:#[10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160]
-            startingAt:1
+	    replaceBytesFrom:0 to:9
+	    with:#[10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160]
+	    startingAt:1
 
      (ExternalBytes unprotectedNew:16)
-            replaceBytesFrom:1 to:10
-            with:#[10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160]
-            startingAt:0
+	    replaceBytesFrom:1 to:10
+	    with:#[10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160]
+	    startingAt:0
     "
 ! !
 
@@ -1310,18 +1310,11 @@
 !ExternalBytes class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/ExternalBytes.st,v 1.84 2012/04/24 14:58:43 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/ExternalBytes.st,v 1.85 2013-01-08 17:55:11 cg Exp $'
 !
 
 version_CVS
-    ^ '§Header: /cvs/stx/stx/libbasic/ExternalBytes.st,v 1.84 2012/04/24 14:58:43 stefan Exp §'
-!
-
-version_SVN
-    ^ '$Id: ExternalBytes.st 10807 2012-05-05 21:58:24Z vranyj1 $'
+    ^ '$Header: /cvs/stx/stx/libbasic/ExternalBytes.st,v 1.85 2013-01-08 17:55:11 cg Exp $'
 ! !
 
 ExternalBytes initialize!
-
-
-