# HG changeset patch # User Claus Gittinger # Date 1050017869 -7200 # Node ID 62450598d2085820e8d5da9ae7043313c371417c # Parent a68adb223592e70822c7fdd8156270f81759c11a also handle subclasses of ExternalBytes (Mapped..) diff -r a68adb223592 -r 62450598d208 UnixFileDescriptorHandle.st --- a/UnixFileDescriptorHandle.st Fri Apr 11 01:35:47 2003 +0200 +++ b/UnixFileDescriptorHandle.st Fri Apr 11 01:37:49 2003 +0200 @@ -38,7 +38,7 @@ if (fd < 0) { goto bad; } - if (__isExternalBytes(aByteBuffer)) { + if (__isExternalBytesLike(aByteBuffer)) { OBJ sz; nInstBytes = 0; @@ -121,7 +121,6 @@ n := h readBytes:10 into:buff startingAt:1. Transcript show:n; space; showCR:buff. " - ! writeBytes:count from:aByteBuffer startingAt:firstIndex @@ -144,7 +143,7 @@ if (fd < 0) { goto bad; } - if (__isExternalBytes(aByteBuffer)) { + if (__isExternalBytesLike(aByteBuffer)) { OBJ sz; nInstBytes = 0; @@ -226,8 +225,6 @@ buff := '12345678901234567890'. n := h writeBytes:10 from:buff startingAt:1. " - - ! ! !UnixFileDescriptorHandle methodsFor:'private accessing'! @@ -262,5 +259,5 @@ !UnixFileDescriptorHandle class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libbasic/UnixFileDescriptorHandle.st,v 1.5 2000-06-24 10:57:35 cg Exp $' + ^ '$Header: /cvs/stx/stx/libbasic/UnixFileDescriptorHandle.st,v 1.6 2003-04-10 23:36:50 cg Exp $' ! ! diff -r a68adb223592 -r 62450598d208 UnixOperatingSystem.st --- a/UnixOperatingSystem.st Fri Apr 11 01:35:47 2003 +0200 +++ b/UnixOperatingSystem.st Fri Apr 11 01:37:49 2003 +0200 @@ -9873,102 +9873,102 @@ int nInstBytes, objSize; if (! __isSmallInteger(__INST(fd))) { - error = @symbol(errorNotOpen); - goto bad; + error = @symbol(errorNotOpen); + goto bad; } if (! __bothSmallInteger(count, firstIndex)) { - error = @symbol(badArgument); - goto bad; + error = @symbol(badArgument); + goto bad; } fd = __smallIntegerVal(__INST(fd)); cnt = __smallIntegerVal(count); offs = __smallIntegerVal(firstIndex) - 1; if (fd < 0) { - error = @symbol(internalError); - goto bad; - } - if (__isExternalBytes(aByteBuffer)) { - OBJ sz; - - nInstBytes = 0; - extPtr = (char *)(__externalBytesAddress(aByteBuffer)); - sz = __externalBytesSize(aByteBuffer); - if (__isSmallInteger(sz)) { - objSize = __smallIntegerVal(sz); - } else { - objSize = -1; /* unknown */ - } + error = @symbol(internalError); + goto bad; + } + if (__isExternalBytesLike(aByteBuffer)) { + OBJ sz; + + nInstBytes = 0; + extPtr = (char *)(__externalBytesAddress(aByteBuffer)); + sz = __externalBytesSize(aByteBuffer); + if (__isSmallInteger(sz)) { + objSize = __smallIntegerVal(sz); + } else { + objSize = -1; /* unknown */ + } } else { - OBJ oClass; - int nInstVars; - - oClass = __Class(aByteBuffer); - switch (__smallIntegerVal(__ClassInstPtr(oClass)->c_flags) & ARRAYMASK) { - case BYTEARRAY: - case WORDARRAY: - case LONGARRAY: - case SWORDARRAY: - case SLONGARRAY: - case FLOATARRAY: - case DOUBLEARRAY: - break; - default: - error = @symbol(badArgument1); - goto bad; - } - extPtr = (char *)0; - nInstVars = __smallIntegerVal(__ClassInstPtr(oClass)->c_ninstvars); - nInstBytes = __OBJS2BYTES__(nInstVars); - objSize = __Size(aByteBuffer) - OHDR_SIZE - nInstBytes; + OBJ oClass; + int nInstVars; + + oClass = __Class(aByteBuffer); + switch (__smallIntegerVal(__ClassInstPtr(oClass)->c_flags) & ARRAYMASK) { + case BYTEARRAY: + case WORDARRAY: + case LONGARRAY: + case SWORDARRAY: + case SLONGARRAY: + case FLOATARRAY: + case DOUBLEARRAY: + break; + default: + error = @symbol(badArgument1); + goto bad; + } + extPtr = (char *)0; + nInstVars = __smallIntegerVal(__ClassInstPtr(oClass)->c_ninstvars); + nInstBytes = __OBJS2BYTES__(nInstVars); + objSize = __Size(aByteBuffer) - OHDR_SIZE - nInstBytes; } if ((offs >= 0) - && (cnt >= 0) - && ((objSize == -1) || (objSize >= (cnt + offs)))) { - nRead = 0; - - do { - int n; - - if (extPtr) { - n = read(fd, extPtr+offs, cnt); - } else { - char *bp; - - /* - * on interrupt, anObject may be moved to another location. - * So we recompute the byte-address here. - */ - bp = __byteArrayVal(aByteBuffer) + nInstBytes; - - n = read(fd, bp + offs, cnt); - } - if (n > 0) { - cnt -= n; - offs += n; - nRead += n; - } else if (n == 0) { - break; - } else if (n < 0) { - if (0 + && (cnt >= 0) + && ((objSize == -1) || (objSize >= (cnt + offs)))) { + nRead = 0; + + do { + int n; + + if (extPtr) { + n = read(fd, extPtr+offs, cnt); + } else { + char *bp; + + /* + * on interrupt, anObject may be moved to another location. + * So we recompute the byte-address here. + */ + bp = __byteArrayVal(aByteBuffer) + nInstBytes; + + n = read(fd, bp + offs, cnt); + } + if (n > 0) { + cnt -= n; + offs += n; + nRead += n; + } else if (n == 0) { + break; + } else if (n < 0) { + if (0 #ifdef EWOULDBLOCK - || errno == EWOULDBLOCK + || errno == EWOULDBLOCK #endif #ifdef EAGAIN - || errno == EAGAIN -#endif - ) { - RETURN(nil); - } - if (errno != EINTR) { - error = __mkSmallInteger(errno); - goto bad; - } - __HANDLE_INTERRUPTS__; - } - } while (cnt > 0); - - RETURN (__mkSmallInteger(nRead)); + || errno == EAGAIN +#endif + ) { + RETURN(nil); + } + if (errno != EINTR) { + error = __mkSmallInteger(errno); + goto bad; + } + __HANDLE_INTERRUPTS__; + } + } while (cnt > 0); + + RETURN (__mkSmallInteger(nRead)); } bad: ; %}. @@ -10007,102 +10007,102 @@ int nInstBytes, objSize; if (! __isSmallInteger(__INST(fd))) { - error = @symbol(errorNotOpen); - goto bad; + error = @symbol(errorNotOpen); + goto bad; } if (! __bothSmallInteger(count, firstIndex)) { - error = @symbol(badArgument); - goto bad; + error = @symbol(badArgument); + goto bad; } fd = __smallIntegerVal(__INST(fd)); cnt = __smallIntegerVal(count); offs = __smallIntegerVal(firstIndex) - 1; if (fd < 0) { - error = @symbol(internalError); - goto bad; - } - if (__isExternalBytes(aByteBuffer)) { - OBJ sz; - - nInstBytes = 0; - extPtr = (char *)(__externalBytesAddress(aByteBuffer)); - sz = __externalBytesSize(aByteBuffer); - if (__isSmallInteger(sz)) { - objSize = __smallIntegerVal(sz); - } else { - objSize = -1; /* unknown */ - } + error = @symbol(internalError); + goto bad; + } + if (__isExternalBytesLike(aByteBuffer)) { + OBJ sz; + + nInstBytes = 0; + extPtr = (char *)(__externalBytesAddress(aByteBuffer)); + sz = __externalBytesSize(aByteBuffer); + if (__isSmallInteger(sz)) { + objSize = __smallIntegerVal(sz); + } else { + objSize = -1; /* unknown */ + } } else { - OBJ oClass; - int nInstVars; - - oClass = __Class(aByteBuffer); - switch (__smallIntegerVal(__ClassInstPtr(oClass)->c_flags) & ARRAYMASK) { - case BYTEARRAY: - case WORDARRAY: - case LONGARRAY: - case SWORDARRAY: - case SLONGARRAY: - case FLOATARRAY: - case DOUBLEARRAY: - break; - default: - error = @symbol(badArgument1); - goto bad; - } - extPtr = (char *)0; - nInstVars = __smallIntegerVal(__ClassInstPtr(oClass)->c_ninstvars); - nInstBytes = __OBJS2BYTES__(nInstVars); - objSize = __Size(aByteBuffer) - OHDR_SIZE - nInstBytes; + OBJ oClass; + int nInstVars; + + oClass = __Class(aByteBuffer); + switch (__smallIntegerVal(__ClassInstPtr(oClass)->c_flags) & ARRAYMASK) { + case BYTEARRAY: + case WORDARRAY: + case LONGARRAY: + case SWORDARRAY: + case SLONGARRAY: + case FLOATARRAY: + case DOUBLEARRAY: + break; + default: + error = @symbol(badArgument1); + goto bad; + } + extPtr = (char *)0; + nInstVars = __smallIntegerVal(__ClassInstPtr(oClass)->c_ninstvars); + nInstBytes = __OBJS2BYTES__(nInstVars); + objSize = __Size(aByteBuffer) - OHDR_SIZE - nInstBytes; } if ((offs >= 0) - && (cnt >= 0) - && ((objSize == -1) || (objSize >= (cnt + offs)))) { - nWritten = 0; - - do { - int n; - - if (extPtr) { - n = write(fd, extPtr+offs, cnt); - } else { - char *bp; - - /* - * on interrupt, anObject may be moved to another location. - * So we recompute the byte-address here. - */ - bp = __byteArrayVal(aByteBuffer) + nInstBytes; - - n = write(fd, bp + offs, cnt); - } - if (n > 0) { - cnt -= n; - offs += n; - nWritten += n; - } else if (n == 0) { - break; - } else if (n < 0) { - if (0 + && (cnt >= 0) + && ((objSize == -1) || (objSize >= (cnt + offs)))) { + nWritten = 0; + + do { + int n; + + if (extPtr) { + n = write(fd, extPtr+offs, cnt); + } else { + char *bp; + + /* + * on interrupt, anObject may be moved to another location. + * So we recompute the byte-address here. + */ + bp = __byteArrayVal(aByteBuffer) + nInstBytes; + + n = write(fd, bp + offs, cnt); + } + if (n > 0) { + cnt -= n; + offs += n; + nWritten += n; + } else if (n == 0) { + break; + } else if (n < 0) { + if (0 #ifdef EWOULDBLOCK - || errno == EWOULDBLOCK + || errno == EWOULDBLOCK #endif #ifdef EAGAIN - || errno == EAGAIN -#endif - ) { - RETURN(nil); - } - if (errno != EINTR) { - error = __mkSmallInteger(errno); - goto bad; - } - __HANDLE_INTERRUPTS__; - } - } while (cnt > 0); - - RETURN (__mkSmallInteger(nWritten)); + || errno == EAGAIN +#endif + ) { + RETURN(nil); + } + if (errno != EINTR) { + error = __mkSmallInteger(errno); + goto bad; + } + __HANDLE_INTERRUPTS__; + } + } while (cnt > 0); + + RETURN (__mkSmallInteger(nWritten)); } bad: ; %}. @@ -12788,7 +12788,7 @@ !UnixOperatingSystem class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.156 2003-04-10 11:03:26 penk Exp $' + ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.157 2003-04-10 23:37:49 cg Exp $' ! ! UnixOperatingSystem initialize!