--- a/ExternalStream.st Wed Feb 12 13:35:00 2014 +0100
+++ b/ExternalStream.st Wed Feb 12 13:54:11 2014 +0100
@@ -3320,7 +3320,7 @@
%{
FILEPOINTER f;
int cnt, offs, ret, _buffered;
- int objSize, nInstVars, nInstBytes;
+ int objSize, nInstBytes;
char *cp;
char *extPtr;
OBJ fp;
@@ -3331,94 +3331,102 @@
|| (__INST(handleType) == @symbol(filePointer))
|| (__INST(handleType) == @symbol(socketFilePointer))
|| (__INST(handleType) == @symbol(pipeFilePointer))) {
- if (((fp = __INST(handle)) != nil)
- && (__INST(mode) != @symbol(writeonly))
- && __bothSmallInteger(count, start)
- ) {
- f = __FILEVal(fp);
-
- cnt = __intVal(count);
- offs = __intVal(start) - 1;
-
- if (__isExternalBytesLike(anObject)) {
- OBJ sz;
-
- nInstBytes = 0;
- extPtr = (char *)(__externalBytesAddress(anObject));
- if (extPtr == NULL) goto bad;
- sz = __externalBytesSize(anObject);
- if (__isSmallInteger(sz)) {
- objSize = __intVal(sz);
- } else {
- objSize = 0; /* unknown */
- }
- } else {
- OBJ oClass;
-
- oClass = __Class(anObject);
- switch (__intVal(__ClassInstPtr(oClass)->c_flags) & ARRAYMASK) {
- case BYTEARRAY:
- case WORDARRAY:
- case LONGARRAY:
- case SWORDARRAY:
- case SLONGARRAY:
- case FLOATARRAY:
- case DOUBLEARRAY:
- break;
- default:
- goto bad;
- }
- extPtr = (char *)0;
- nInstVars = __intVal(__ClassInstPtr(oClass)->c_ninstvars);
- nInstBytes = OHDR_SIZE + __OBJS2BYTES__(nInstVars);
- objSize = __Size(anObject) - nInstBytes;
- }
-
- if ((offs >= 0) && (cnt >= 0) && (objSize >= (cnt + offs))) {
- _buffered = (__INST(buffered) == true);
- if (_buffered) {
- __READING__(f);
- }
-
- if (extPtr) {
- __READAVAILBYTES__(ret, f, extPtr+offs, cnt, _buffered, __INST(handleType));
- } else {
- /*
- * on interrupt, anObject may be moved to another location.
- * So we pass (char *)__InstPtr(anObject) + nInstBytes + offs to the macro __READ_BYTES__,
- * to get a new address.
- */
- offs += nInstBytes;
- __READAVAILBYTES_OBJ__(ret, f, anObject, offs, cnt, _buffered, __INST(handleType));
- }
+ if (((fp = __INST(handle)) != nil)
+ && (__INST(mode) != @symbol(writeonly))
+ && __bothSmallInteger(count, start)
+ ) {
+ f = __FILEVal(fp);
+
+ cnt = __intVal(count);
+ offs = __intVal(start) - 1;
+
+ if (__isExternalBytesLike(anObject)) {
+ OBJ sz;
+
+ nInstBytes = 0;
+ extPtr = (char *)(__externalBytesAddress(anObject));
+ if (extPtr == NULL) goto bad;
+ sz = __externalBytesSize(anObject);
+ if (__isSmallInteger(sz)) {
+ objSize = __intVal(sz);
+ } else {
+ objSize = 0; /* unknown */
+ }
+ } else {
+ OBJ oClass = __Class(anObject);
+ int nInstVars = __intVal(__ClassInstPtr(oClass)->c_ninstvars);
+
+ nInstBytes = OHDR_SIZE + __OBJS2BYTES__(nInstVars);
+
+ switch (__intVal(__ClassInstPtr(oClass)->c_flags) & ARRAYMASK) {
+ case BYTEARRAY:
+ case WORDARRAY:
+ case LONGARRAY:
+ case SWORDARRAY:
+ case SLONGARRAY:
+ case FLOATARRAY:
+ case DOUBLEARRAY:
+#ifdef __NEED_DOUBLE_ALIGN
+ nInstBytes = (nInstBytes-1+__DOUBLE_ALIGN) &~ (__DOUBLE_ALIGN-1);
+#endif
+ break;
+ case LONGLONGARRAY:
+ case SLONGLONGARRAY:
+#ifdef __NEED_LONGLONG_ALIGN
+ nInstBytes = (nInstBytes-1+__LONGLONG_ALIGN) &~ (__LONGLONG_ALIGN-1);
+#endif
+ default:
+ goto bad;
+ }
+ extPtr = (char *)0;
+ objSize = __Size(anObject) - nInstBytes;
+ }
+
+ if ((offs >= 0) && (cnt >= 0) && (objSize >= (cnt + offs))) {
+ _buffered = (__INST(buffered) == true);
+ if (_buffered) {
+ __READING__(f);
+ }
+
+ if (extPtr) {
+ __READAVAILBYTES__(ret, f, extPtr+offs, cnt, _buffered, __INST(handleType));
+ } else {
+ /*
+ * on interrupt, anObject may be moved to another location.
+ * So we pass (char *)__InstPtr(anObject) + nInstBytes + offs to the macro __READ_BYTES__,
+ * to get a new address.
+ */
+ offs += nInstBytes;
+ __READAVAILBYTES_OBJ__(ret, f, anObject, offs, cnt, _buffered, __INST(handleType));
+ }
#ifdef PRE_22_jan_2000
- if (ret > 0)
+ if (ret > 0)
#else
- /* 0 is NOT an EOF condition here ... */
- if (ret >= 0)
+ /* 0 is NOT an EOF condition here ... */
+ if (ret >= 0)
#endif
- {
- if (__isSmallInteger(__INST(position))) {
- INT np = __intVal(__INST(position)) + ret;
- OBJ t;
-
- t = __MKINT(np); __INST(position) = t; __STORE(self, t);
- } else {
- __INST(position) = nil; /* i.e. do not know */
- }
- RETURN (__mkSmallInteger(ret));
- }
+ {
+ if (__isSmallInteger(__INST(position))) {
+ INT np = __intVal(__INST(position)) + ret;
+ OBJ t;
+
+ t = __MKINT(np); __INST(position) = t; __STORE(self, t);
+ } else {
+ __INST(position) = nil; /* i.e. do not know */
+ }
+ RETURN (__mkSmallInteger(ret));
+ }
#ifdef PRE_22_jan_2000
- if (ret == 0) {
- __INST(hitEOF) = true;
- } else /* ret < 0 */
+ if (ret == 0) {
+ __INST(hitEOF) = true;
+ } else /* ret < 0 */
#endif
- {
- __INST(position) = nil;
- __INST(lastErrorNumber) = __mkSmallInteger(__threadErrno);
- }
- }
- }
+ {
+ __INST(position) = nil;
+ __INST(lastErrorNumber) = __mkSmallInteger(__threadErrno);
+ }
+ }
+ }
}
bad: ;
%}.
@@ -3512,7 +3520,7 @@
%{
FILEPOINTER f;
int cnt, offs, ret, _buffered;
- int objSize, nInstVars, nInstBytes;
+ int objSize, nInstBytes;
char *extPtr;
OBJ fp;
@@ -3521,84 +3529,91 @@
|| (__INST(handleType) == @symbol(filePointer))
|| (__INST(handleType) == @symbol(socketFilePointer))
|| (__INST(handleType) == @symbol(pipeFilePointer))) {
- if (((fp = __INST(handle)) != nil)
- && (__INST(mode) != @symbol(writeonly))
- && __bothSmallInteger(count, start)
- ) {
- f = __FILEVal(fp);
-
- cnt = __intVal(count);
- offs = __intVal(start) - 1;
-
- if (__isExternalBytesLike(anObject)) {
- OBJ sz;
-
- nInstBytes = 0;
- extPtr = (char *)(__externalBytesAddress(anObject));
- if (extPtr == NULL) goto bad;
- sz = __externalBytesSize(anObject);
- if (__isSmallInteger(sz)) {
- objSize = __intVal(sz);
- } else {
- objSize = 0; /* unknown */
- }
- } else {
- OBJ oClass;
-
- oClass = __Class(anObject);
- switch (__intVal(__ClassInstPtr(oClass)->c_flags) & ARRAYMASK) {
- case BYTEARRAY:
- case WORDARRAY:
- case LONGARRAY:
- case SWORDARRAY:
- case SLONGARRAY:
- case FLOATARRAY:
- case DOUBLEARRAY:
- break;
- default:
- goto bad;
- }
- extPtr = (char *)0;
- nInstVars = __intVal(__ClassInstPtr(oClass)->c_ninstvars);
- nInstBytes = OHDR_SIZE + __OBJS2BYTES__(nInstVars);
- objSize = __Size(anObject) - nInstBytes;
- }
- if ((offs >= 0) && (cnt >= 0) && (objSize >= (cnt + offs))) {
- _buffered = (__INST(buffered) == true);
- if (_buffered) {
- __READING__(f);
- }
-
- if (extPtr) {
- __READBYTES__(ret, f, extPtr+offs, cnt, _buffered, __INST(handleType));
- } else {
- /*
- * on interrupt, anObject may be moved to another location.
- * So we pass anObject, and the offset to the __READBYTES_OBJ__ macro.
- */
- offs += nInstBytes;
- __READBYTES_OBJ__(ret, f, anObject, offs, cnt, _buffered, __INST(handleType));
- }
-
- if (ret > 0) {
- if (__isSmallInteger(__INST(position))) {
- INT np = __intVal(__INST(position)) + ret;
- OBJ t;
-
- t = __MKINT(np); __INST(position) = t; __STORE(self, t);
- } else {
- __INST(position) = nil; /* i.e. do not know */
- }
- RETURN (__mkSmallInteger(ret));
- }
- if (ret == 0) {
- __INST(hitEOF) = true;
- } else /* ret < 0 */ {
- __INST(position) = nil;
- __INST(lastErrorNumber) = __mkSmallInteger(__threadErrno);
- }
- }
- }
+ if (((fp = __INST(handle)) != nil)
+ && (__INST(mode) != @symbol(writeonly))
+ && __bothSmallInteger(count, start)
+ ) {
+ f = __FILEVal(fp);
+
+ cnt = __intVal(count);
+ offs = __intVal(start) - 1;
+
+ if (__isExternalBytesLike(anObject)) {
+ OBJ sz;
+
+ nInstBytes = 0;
+ extPtr = (char *)(__externalBytesAddress(anObject));
+ if (extPtr == NULL) goto bad;
+ sz = __externalBytesSize(anObject);
+ if (__isSmallInteger(sz)) {
+ objSize = __intVal(sz);
+ } else {
+ objSize = 0; /* unknown */
+ }
+ } else {
+ OBJ oClass = __Class(anObject);
+ int nInstVars = __intVal(__ClassInstPtr(oClass)->c_ninstvars);
+
+ nInstBytes = OHDR_SIZE + __OBJS2BYTES__(nInstVars);
+ switch (__intVal(__ClassInstPtr(oClass)->c_flags) & ARRAYMASK) {
+ case BYTEARRAY:
+ case WORDARRAY:
+ case LONGARRAY:
+ case SWORDARRAY:
+ case SLONGARRAY:
+ case FLOATARRAY:
+ case DOUBLEARRAY:
+#ifdef __NEED_DOUBLE_ALIGN
+ nInstBytes = (nInstBytes-1+__DOUBLE_ALIGN) &~ (__DOUBLE_ALIGN-1);
+#endif
+ break;
+ case LONGLONGARRAY:
+ case SLONGLONGARRAY:
+#ifdef __NEED_LONGLONG_ALIGN
+ nInstBytes = (nInstBytes-1+__LONGLONG_ALIGN) &~ (__LONGLONG_ALIGN-1);
+#endif
+ default:
+ goto bad;
+ }
+ extPtr = (char *)0;
+ objSize = __Size(anObject) - nInstBytes;
+ }
+ if ((offs >= 0) && (cnt >= 0) && (objSize >= (cnt + offs))) {
+ _buffered = (__INST(buffered) == true);
+ if (_buffered) {
+ __READING__(f);
+ }
+
+ if (extPtr) {
+ __READBYTES__(ret, f, extPtr+offs, cnt, _buffered, __INST(handleType));
+ } else {
+ /*
+ * on interrupt, anObject may be moved to another location.
+ * So we pass anObject, and the offset to the __READBYTES_OBJ__ macro.
+ */
+ offs += nInstBytes;
+ __READBYTES_OBJ__(ret, f, anObject, offs, cnt, _buffered, __INST(handleType));
+ }
+
+ if (ret > 0) {
+ if (__isSmallInteger(__INST(position))) {
+ INT np = __intVal(__INST(position)) + ret;
+ OBJ t;
+
+ t = __MKINT(np); __INST(position) = t; __STORE(self, t);
+ } else {
+ __INST(position) = nil; /* i.e. do not know */
+ }
+ RETURN (__mkSmallInteger(ret));
+ }
+ if (ret == 0) {
+ __INST(hitEOF) = true;
+ } else /* ret < 0 */ {
+ __INST(position) = nil;
+ __INST(lastErrorNumber) = __mkSmallInteger(__threadErrno);
+ }
+ }
+ }
}
bad: ;
%}.
@@ -4031,7 +4046,7 @@
%{
FILEPOINTER f;
int cnt, len, offs, ret;
- int objSize, nInstVars, nInstBytes, _buffered;
+ int objSize, nInstBytes, _buffered;
char *extPtr;
OBJ fp;
@@ -4061,9 +4076,10 @@
objSize = 0; /* unknown */
}
} else {
- OBJ oClass;
-
- oClass = __Class(anObject);
+ OBJ oClass = __Class(anObject);
+ int nInstVars = __intVal(__ClassInstPtr(oClass)->c_ninstvars);
+
+ nInstBytes = OHDR_SIZE + __OBJS2BYTES__(nInstVars);
switch (__intVal(__ClassInstPtr(oClass)->c_flags) & ARRAYMASK) {
case BYTEARRAY:
case WORDARRAY:
@@ -4071,14 +4087,22 @@
case SWORDARRAY:
case SLONGARRAY:
case FLOATARRAY:
+ break;
case DOUBLEARRAY:
+#ifdef __NEED_DOUBLE_ALIGN
+ nInstBytes = (nInstBytes-1+__DOUBLE_ALIGN) &~ (__DOUBLE_ALIGN-1);
+#endif
+ break;
+ case LONGLONGARRAY:
+ case SLONGLONGARRAY:
+#ifdef __NEED_LONGLONG_ALIGN
+ nInstBytes = (nInstBytes-1+__LONGLONG_ALIGN) &~ (__LONGLONG_ALIGN-1);
+#endif
break;
default:
goto bad;
}
extPtr = (char *)0;
- nInstVars = __intVal(__ClassInstPtr(oClass)->c_ninstvars);
- nInstBytes = OHDR_SIZE + __OBJS2BYTES__(nInstVars);
objSize = __Size(anObject) - nInstBytes;
}
if ( (offs >= 0) && (len >= 0) && (objSize >= (len + offs)) ) {
@@ -5832,11 +5856,11 @@
!ExternalStream class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/ExternalStream.st,v 1.378 2014-01-29 13:35:20 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/ExternalStream.st,v 1.379 2014-02-12 12:54:11 stefan Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libbasic/ExternalStream.st,v 1.378 2014-01-29 13:35:20 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/ExternalStream.st,v 1.379 2014-02-12 12:54:11 stefan Exp $'
! !