--- a/ExternalStream.st Tue May 17 00:56:14 2016 +0200
+++ b/ExternalStream.st Tue May 17 02:04:25 2016 +0200
@@ -66,7 +66,7 @@
# define SEEK_END 2
#endif
-#if defined(__VMS__) || defined(__sparc__) || defined(WIN32)
+#if defined(__VMS__) || defined(__sparc__) || defined(__win32__)
# define CLEAR_ERRNO __threadErrno = 0;
#else
# define CLEAR_ERRNO /* nothing */
@@ -80,7 +80,7 @@
# define __MKFILEPOINTER(f) __MKEXTERNALADDRESS(f)
#endif
-#ifdef WIN32
+#ifdef __win32__
# define NO_STDIO
# undef __HANDLE_INTERRUPTS__
@@ -97,7 +97,7 @@
# define _X86_
# endif
-#ifdef WIN32
+#ifdef __win32__
# undef INT
# undef UINT
# undef Array
@@ -188,7 +188,7 @@
# ifndef off_t
# define off_t long
# endif
-#endif /* WIN32 */
+#endif /* __win32__ */
#ifndef NO_STDIO /* use STDIO */
# define STDIO_NEEDS_FSEEK
@@ -223,7 +223,7 @@
# define OPT_FSEEK(f, pos, whence) /* nothing */
#endif
-#ifdef WIN32
+#ifdef __win32__
// Win returns from ReadFile() with false and _threadErrno == 0 on end of pipe.
// We don't know why
# define READ(ret, f, cp, n, handleType) { \
@@ -692,7 +692,7 @@
} \
}
-#else /* ! WIN32 */
+#else /* ! __win32__ */
/* ======================== UNIX / LINUX ====================================================== */
typedef int SOCKET;
@@ -1504,24 +1504,24 @@
initDefaultEOLMode
OperatingSystem isUNIXlike ifTrue:[
- "/ unix EOL conventions
- DefaultEOLMode := #nl
+ "/ unix EOL conventions
+ DefaultEOLMode := #nl
] ifFalse:[
- OperatingSystem isVMSlike ifTrue:[
- "/ vms EOL conventions
- DefaultEOLMode := #cr
- ] ifFalse:[
- "/ msdos EOL conventions
- "/ msdos uses #crlf.
- "/ the following breaks all programs, which do not explicitly
- "/ change th eolMode when writing/reading binary files (zip reader)
- "/ MUST change all classes before doing the following.
- "/ Anyway: for backward compatibility (swisscom), it is left in this
- "/ mode (for a while, I hope).
- DefaultEOLMode := #crlf.
-
- "/ DefaultEOLMode := #nl
- ]
+ OperatingSystem isVMSlike ifTrue:[
+ "/ vms EOL conventions
+ DefaultEOLMode := #cr
+ ] ifFalse:[
+ "/ msdos EOL conventions
+ "/ msdos uses #crlf.
+ "/ the following breaks all programs, which do not explicitly
+ "/ change th eolMode when writing/reading binary files (zip reader)
+ "/ MUST change all classes before doing the following.
+ "/ Anyway: for backward compatibility (swisscom), it is left in this
+ "/ mode (for a while, I hope).
+ DefaultEOLMode := #crlf.
+
+ "/ DefaultEOLMode := #nl
+ ]
]
!
@@ -1546,41 +1546,41 @@
initialize
OpenErrorSignal isNil ifTrue:[
- OpenErrorSignal := OpenError.
- OpenErrorSignal notifierString:'open error'.
-
- InvalidReadSignal := InvalidReadError.
- InvalidReadSignal notifierString:'stream does not support reading'.
-
- InvalidWriteSignal := InvalidWriteError.
- InvalidWriteSignal notifierString:'stream does not support writing'.
-
- InvalidModeSignal := InvalidModeError.
- InvalidModeSignal notifierString:'binary/text mode mismatch'.
-
- InvalidOperationSignal := InvalidOperationError.
- InvalidOperationSignal notifierString:'unsupported file operation'.
-
- StreamNotOpenSignal := StreamNotOpenError.
- StreamNotOpenSignal notifierString:'stream is not open'.
-
- StreamIOErrorSignal := StreamIOError.
- StreamIOErrorSignal notifierString:'I/O error'.
-
- "/ self patchByteOrderOptimizedMethods
+ OpenErrorSignal := OpenError.
+ OpenErrorSignal notifierString:'open error'.
+
+ InvalidReadSignal := InvalidReadError.
+ InvalidReadSignal notifierString:'stream does not support reading'.
+
+ InvalidWriteSignal := InvalidWriteError.
+ InvalidWriteSignal notifierString:'stream does not support writing'.
+
+ InvalidModeSignal := InvalidModeError.
+ InvalidModeSignal notifierString:'binary/text mode mismatch'.
+
+ InvalidOperationSignal := InvalidOperationError.
+ InvalidOperationSignal notifierString:'unsupported file operation'.
+
+ StreamNotOpenSignal := StreamNotOpenError.
+ StreamNotOpenSignal notifierString:'stream is not open'.
+
+ StreamIOErrorSignal := StreamIOError.
+ StreamIOErrorSignal notifierString:'I/O error'.
+
+ "/ self patchByteOrderOptimizedMethods
].
Lobby isNil ifTrue:[
- Lobby := Registry new.
-
- "want to get informed when returning from snapshot"
- ObjectMemory addDependent:self
+ Lobby := Registry new.
+
+ "want to get informed when returning from snapshot"
+ ObjectMemory addDependent:self
].
DefaultEOLMode isNil ifTrue:[
- self initDefaultEOLMode.
+ self initDefaultEOLMode.
].
ReadMode isNil ifTrue:[
- self initModeStrings.
+ self initModeStrings.
].
"limit the amount of newspace to be used for non-tenurable executors to 5%"
@@ -1595,21 +1595,21 @@
patchByteOrderOptimizedMethods
"EXPERIMENTAL (not yet done by default):
change the underlying implementation of
- nextPutInt16MSB / nextPutInt16LSB
- nextPutInt32MSB / nextPutInt32LSB
+ nextPutInt16MSB / nextPutInt16LSB
+ nextPutInt32MSB / nextPutInt32LSB
to the corresponding NATIVE methods."
|native16 native32|
-
+
native16 := self compiledMethodAt:#nextPutInt16NATIVE:.
native32 := self compiledMethodAt:#nextPutInt32NATIVE:.
-
+
UninterpretedBytes isBigEndian ifTrue:[
- (self compiledMethodAt:#nextPutInt16MSB:) code:(native16 code).
- (self compiledMethodAt:#nextPutInt32MSB:) code:(native32 code).
+ (self compiledMethodAt:#nextPutInt16MSB:) code:(native16 code).
+ (self compiledMethodAt:#nextPutInt32MSB:) code:(native32 code).
] ifFalse:[
- (self compiledMethodAt:#nextPutInt16LSB:) code:(native16 code).
- (self compiledMethodAt:#nextPutInt32LSB:) code:(native32 code).
+ (self compiledMethodAt:#nextPutInt16LSB:) code:(native16 code).
+ (self compiledMethodAt:#nextPutInt32LSB:) code:(native32 code).
].
!
@@ -2148,7 +2148,7 @@
|| (__INST(handleType) == @symbol(filePointer))
|| (__INST(handleType) == @symbol(socketFilePointer))
|| (__INST(handleType) == @symbol(pipeFilePointer))) {
-#ifdef WIN32
+#ifdef __win32__
RETURN(__MKEXTERNALADDRESS(_get_osfhandle(fileno(__FILEVal(_handle)))));
#else
RETURN (__MKINT(fileno(__FILEVal(_handle))));
@@ -2774,7 +2774,7 @@
if (_buffered) {
__WRITING__(f)
}
-#ifdef WIN32
+#ifdef __win32__
if ((f == __win32_stdout()) || (f == __win32_stderr())) {
cnt = __win32_fwrite(__stringVal(aString), 1, len, f);
} else
@@ -2799,7 +2799,7 @@
} else {
cp = "\n"; len = 1;
}
-#ifdef WIN32
+#ifdef __win32__
if ((f == __win32_stdout()) || (f == __win32_stderr())) {
cnt = __win32_fwrite(cp, 1, len, f);
} else
@@ -2991,14 +2991,14 @@
|bufferSize|
(self isFileStream and:[outStream isFileStream]) ifTrue:[
- bufferSize := 8192 * 8. "/ 64k buffer size
- ] ifFalse:[
- OperatingSystem isMSDOSlike ifTrue:[
- "/ mhmh - NT hangs, when copying bigger blocks to a network drive - why ?
- bufferSize := 1 * 1024.
- ] ifFalse:[
- bufferSize := 8 * 1024.
- ].
+ bufferSize := 8192 * 8. "/ 64k buffer size
+ ] ifFalse:[
+ OperatingSystem isMSDOSlike ifTrue:[
+ "/ mhmh - NT hangs, when copying bigger blocks to a network drive - why ?
+ bufferSize := 1 * 1024.
+ ] ifFalse:[
+ bufferSize := 8 * 1024.
+ ].
].
^ self copyToEndInto:outStream bufferSize:bufferSize
@@ -3163,7 +3163,7 @@
goto out;
}
-#ifdef WIN32
+#ifdef __win32__
__threadErrno = 0;
ret = __STX_API_NOINT_CALL1( "FlushFileBuffers", FlushFileBuffers, _get_osfhandle(fd));
if (ret) {
@@ -3179,7 +3179,7 @@
if (ret >= 0) {
RETURN (self);
}
-#endif /* ! WIN32 */
+#endif /* ! __win32__ */
error = __mkSmallInteger(__threadErrno);
#endif /* ! __openVMS__ */
out:;
@@ -3232,7 +3232,7 @@
goto out;
}
-#ifdef WIN32
+#ifdef __win32__
__threadErrno = 0;
ret = __STX_API_NOINT_CALL1( "FlushFileBuffers", FlushFileBuffers, _get_osfhandle(fd));
if (ret) {
@@ -3248,7 +3248,7 @@
if (ret >= 0) {
RETURN (self);
}
-#endif /* ! WIN32 */
+#endif /* ! __win32__ */
error = __mkSmallInteger(__threadErrno);
#endif /* ! __openVMS__ */
out:;
@@ -3969,66 +3969,66 @@
|| (__INST(handleType) == @symbol(socketFilePointer))
|| (__INST(handleType) == @symbol(socketHandle))
|| (__INST(handleType) == @symbol(pipeFilePointer))) {
- if (((fp = __INST(handle)) != nil)
- && (__INST(mode) != @symbol(writeonly))
- ) {
- FILEPOINTER f;
- int ret, _buffered;
- int value;
- union {
- unsigned char buffer[4];
- int intVal;
- } u;
-
- f = __FILEVal(fp);
- _buffered = (__INST(buffered) == true);
- if (_buffered) {
- __READING__(f)
- }
- __READBYTES__(ret, f, u.buffer, 4, _buffered, __INST(handleType));
-
- if (ret == 4) {
- if (__isSmallInteger(__INST(position))) {
- INT np = __intVal(__INST(position)) + 4;
- OBJ t;
-
- t = __MKINT(np); __INST(position) = t; __STORE(self, t);
- } else {
- __INST(position) = nil; /* i.e. do not know */
- }
- if (msbFlag == true) {
+ if (((fp = __INST(handle)) != nil)
+ && (__INST(mode) != @symbol(writeonly))
+ ) {
+ FILEPOINTER f;
+ int ret, _buffered;
+ int value;
+ union {
+ unsigned char buffer[4];
+ int intVal;
+ } u;
+
+ f = __FILEVal(fp);
+ _buffered = (__INST(buffered) == true);
+ if (_buffered) {
+ __READING__(f)
+ }
+ __READBYTES__(ret, f, u.buffer, 4, _buffered, __INST(handleType));
+
+ if (ret == 4) {
+ if (__isSmallInteger(__INST(position))) {
+ INT np = __intVal(__INST(position)) + 4;
+ OBJ t;
+
+ t = __MKINT(np); __INST(position) = t; __STORE(self, t);
+ } else {
+ __INST(position) = nil; /* i.e. do not know */
+ }
+ if (msbFlag == true) {
#if defined(__MSBFIRST__)
- value = u.intVal;
+ value = u.intVal;
#else
- value = (u.buffer[0] & 0xFF);
- value = (value << 8) | (u.buffer[1] & 0xFF);
- value = (value << 8) | (u.buffer[2] & 0xFF);
- value = (value << 8) | (u.buffer[3] & 0xFF);
+ value = (u.buffer[0] & 0xFF);
+ value = (value << 8) | (u.buffer[1] & 0xFF);
+ value = (value << 8) | (u.buffer[2] & 0xFF);
+ value = (value << 8) | (u.buffer[3] & 0xFF);
#endif
- } else {
+ } else {
#if defined(__LSBFIRST__)
- value = u.intVal;
+ value = u.intVal;
#else
- value = (u.buffer[3] & 0xFF);
- value = (value << 8) | (u.buffer[2] & 0xFF);
- value = (value << 8) | (u.buffer[1] & 0xFF);
- value = (value << 8) | (u.buffer[0] & 0xFF);
+ value = (u.buffer[3] & 0xFF);
+ value = (value << 8) | (u.buffer[2] & 0xFF);
+ value = (value << 8) | (u.buffer[1] & 0xFF);
+ value = (value << 8) | (u.buffer[0] & 0xFF);
#endif
- }
+ }
#if __POINTER_SIZE__ == 8
- RETURN ( __mkSmallInteger(value));
+ RETURN ( __mkSmallInteger(value));
#else
- RETURN ( __MKINT(value) );
+ RETURN ( __MKINT(value) );
#endif
- }
-
- if (ret < 0) {
- __INST(position) = nil;
- error = __mkSmallInteger(__threadErrno);
- } else /* ret == 0 */ {
- __INST(hitEOF) = true;
- }
- }
+ }
+
+ if (ret < 0) {
+ __INST(position) = nil;
+ error = __mkSmallInteger(__threadErrno);
+ } else /* ret == 0 */ {
+ __INST(hitEOF) = true;
+ }
+ }
}
%}.
hitEOF ifTrue:[^ self pastEndRead].
@@ -4208,15 +4208,15 @@
nextWord
<resource: #obsolete>
"in text-mode:
- read the alphaNumeric next word (i.e. up to non letter-or-digit).
- return a string containing those characters.
+ read the alphaNumeric next word (i.e. up to non letter-or-digit).
+ return a string containing those characters.
in binary-mode:
- read two bytes (msb-first) and return the value as a 16-bit
- unsigned Integer (for compatibility with other smalltalks)"
+ read two bytes (msb-first) and return the value as a 16-bit
+ unsigned Integer (for compatibility with other smalltalks)"
binary ifTrue:[
- self obsoleteMethodWarning:'use #nextUnsignedShortMSB:true'.
- ^ self nextUnsignedInt16MSB:true
+ self obsoleteMethodWarning:'use #nextUnsignedShortMSB:true'.
+ ^ self nextUnsignedInt16MSB:true
].
self obsoleteMethodWarning:'use #nextAlphaNumericWord'.
^ self nextAlphaNumericWord
@@ -4252,7 +4252,7 @@
if (_buffered) {
__WRITING__(f)
}
-#ifdef WIN32
+#ifdef __win32__
if ((f == __win32_stdout()) || (f == __win32_stderr())) {
cnt = __win32_fwrite(&c, 1, 1, f);
} else
@@ -4285,8 +4285,8 @@
!
nextPutInt16:anIntegerOrCharacter MSB:msbFlag
- "Write the argument, anIntegerOrCharacter as a short (two bytes).
- If msbFlag is true, data is written most-significant byte first;
+ "Write the argument, anIntegerOrCharacter as a short (two bytes).
+ If msbFlag is true, data is written most-significant byte first;
otherwise least first.
Notice that integers in the range -16r8000 to +16rFFFF can be written
(i.e. both signed and unsigned int32 values can be written.
@@ -4296,8 +4296,8 @@
%{
int num;
union {
- char bytes[2];
- short shortVal;
+ char bytes[2];
+ short shortVal;
} u;
OBJ fp;
@@ -4307,62 +4307,62 @@
|| (__INST(handleType) == @symbol(socketFilePointer))
|| (__INST(handleType) == @symbol(socketHandle))
|| (__INST(handleType) == @symbol(pipeFilePointer))) {
- if (((fp = __INST(handle)) != nil)
- && (__INST(mode) != @symbol(readonly))
- ) {
- FILEPOINTER f = __FILEVal(fp);
- int _buffered = (__INST(buffered) == true);
- int cnt;
-
- if (__isSmallInteger(anIntegerOrCharacter)) {
- num = __intVal(anIntegerOrCharacter);
- } else if (__isCharacter(anIntegerOrCharacter)) {
- num = __smallIntegerVal(__characterVal(anIntegerOrCharacter));
- } else
- goto out;
-
- if (msbFlag == true) {
+ if (((fp = __INST(handle)) != nil)
+ && (__INST(mode) != @symbol(readonly))
+ ) {
+ FILEPOINTER f = __FILEVal(fp);
+ int _buffered = (__INST(buffered) == true);
+ int cnt;
+
+ if (__isSmallInteger(anIntegerOrCharacter)) {
+ num = __intVal(anIntegerOrCharacter);
+ } else if (__isCharacter(anIntegerOrCharacter)) {
+ num = __smallIntegerVal(__characterVal(anIntegerOrCharacter));
+ } else
+ goto out;
+
+ if (msbFlag == true) {
#if defined(__MSBFIRST__)
- u.shortVal = num;
+ u.shortVal = num;
#else
- u.bytes[0] = (num >> 8) & 0xFF;
- u.bytes[1] = num & 0xFF;
+ u.bytes[0] = (num >> 8) & 0xFF;
+ u.bytes[1] = num & 0xFF;
#endif
- } else {
+ } else {
#if defined(__LSBFIRST__)
- u.shortVal = num;
+ u.shortVal = num;
#else
- u.bytes[1] = (num >> 8) & 0xFF;
- u.bytes[0] = num & 0xFF;
+ u.bytes[1] = (num >> 8) & 0xFF;
+ u.bytes[0] = num & 0xFF;
#endif
- }
-
- if (_buffered) {
- __WRITING__(f)
- }
- __WRITEBYTES__(cnt, f, u.bytes, 2, _buffered, __INST(handleType));
-
- if (cnt == 2) {
- if (__isSmallInteger(__INST(position))) {
- INT np = __intVal(__INST(position)) + 2;
- OBJ t;
-
- t = __MKINT(np); __INST(position) = t; __STORE(self, t);
- } else {
- __INST(position) = nil; /* i.e. do not know */
- }
- RETURN ( self );
- }
- __INST(position) = nil; /* i.e. do not know */
- error = __mkSmallInteger(__threadErrno);
- }
+ }
+
+ if (_buffered) {
+ __WRITING__(f)
+ }
+ __WRITEBYTES__(cnt, f, u.bytes, 2, _buffered, __INST(handleType));
+
+ if (cnt == 2) {
+ if (__isSmallInteger(__INST(position))) {
+ INT np = __intVal(__INST(position)) + 2;
+ OBJ t;
+
+ t = __MKINT(np); __INST(position) = t; __STORE(self, t);
+ } else {
+ __INST(position) = nil; /* i.e. do not know */
+ }
+ RETURN ( self );
+ }
+ __INST(position) = nil; /* i.e. do not know */
+ error = __mkSmallInteger(__threadErrno);
+ }
}
out:;
%}.
error notNil ifTrue:[
- lastErrorNumber := error.
- self writeError:error.
- ^ self
+ lastErrorNumber := error.
+ self writeError:error.
+ ^ self
].
handle isNil ifTrue:[self errorNotOpen. ^ self].
(mode == #readonly) ifTrue:[self errorReadOnly. ^ self].
@@ -4372,19 +4372,19 @@
nextPutInt16LSB:anIntegerOrCharacter
"do not remove.
See #patchByteOrderOptimizedMethods"
-
+
self nextPutInt16:anIntegerOrCharacter MSB:false
!
nextPutInt16MSB:anIntegerOrCharacter
"do not remove.
See #patchByteOrderOptimizedMethods"
-
+
self nextPutInt16:anIntegerOrCharacter MSB:true
!
-nextPutInt16NATIVE:anIntegerOrCharacter
- "Write the argument, anIntegerOrCharacter as a short (two bytes) in native byte order.
+nextPutInt16NATIVE:anIntegerOrCharacter
+ "Write the argument, anIntegerOrCharacter as a short (two bytes) in native byte order.
This is the CPU-specific byte order (LSB on x86, MSB on sparc, VAX and possibly on ARM).
Notice that integers in the range -16r8000 to +16rFFFF can be written
(i.e. both signed and unsigned int32 values can be written.
@@ -4394,8 +4394,8 @@
%{
int num;
union {
- char bytes[2];
- short shortVal;
+ char bytes[2];
+ short shortVal;
} u;
OBJ fp;
@@ -4405,41 +4405,41 @@
|| (__INST(handleType) == @symbol(socketFilePointer))
|| (__INST(handleType) == @symbol(socketHandle))
|| (__INST(handleType) == @symbol(pipeFilePointer))) {
- if (((fp = __INST(handle)) != nil)
- && (__INST(mode) != @symbol(readonly))
- ) {
- FILEPOINTER f = __FILEVal(fp);
- int _buffered = (__INST(buffered) == true);
- int cnt;
-
- if (__isSmallInteger(anIntegerOrCharacter)) {
- num = __intVal(anIntegerOrCharacter);
- } else if (__isCharacter(anIntegerOrCharacter)) {
- num = __smallIntegerVal(__characterVal(anIntegerOrCharacter));
- } else
- goto out;
-
- u.shortVal = num;
-
- if (_buffered) {
- __WRITING__(f)
- }
- __WRITEBYTES__(cnt, f, u.bytes, 2, _buffered, __INST(handleType));
-
- if (cnt == 2) {
- if (__isSmallInteger(__INST(position))) {
- INT np = __intVal(__INST(position)) + 2;
- OBJ t;
-
- t = __MKINT(np); __INST(position) = t; __STORE(self, t);
- } else {
- __INST(position) = nil; /* i.e. do not know */
- }
- RETURN ( self );
- }
- __INST(position) = nil; /* i.e. do not know */
- error = __mkSmallInteger(__threadErrno);
- }
+ if (((fp = __INST(handle)) != nil)
+ && (__INST(mode) != @symbol(readonly))
+ ) {
+ FILEPOINTER f = __FILEVal(fp);
+ int _buffered = (__INST(buffered) == true);
+ int cnt;
+
+ if (__isSmallInteger(anIntegerOrCharacter)) {
+ num = __intVal(anIntegerOrCharacter);
+ } else if (__isCharacter(anIntegerOrCharacter)) {
+ num = __smallIntegerVal(__characterVal(anIntegerOrCharacter));
+ } else
+ goto out;
+
+ u.shortVal = num;
+
+ if (_buffered) {
+ __WRITING__(f)
+ }
+ __WRITEBYTES__(cnt, f, u.bytes, 2, _buffered, __INST(handleType));
+
+ if (cnt == 2) {
+ if (__isSmallInteger(__INST(position))) {
+ INT np = __intVal(__INST(position)) + 2;
+ OBJ t;
+
+ t = __MKINT(np); __INST(position) = t; __STORE(self, t);
+ } else {
+ __INST(position) = nil; /* i.e. do not know */
+ }
+ RETURN ( self );
+ }
+ __INST(position) = nil; /* i.e. do not know */
+ error = __mkSmallInteger(__threadErrno);
+ }
}
out:;
%}.
@@ -4447,8 +4447,8 @@
!
nextPutInt32:aNumber MSB:msbFlag
- "Write the argument, aNumber as a long (four bytes).
- If msbFlag is true, data is written most-significant byte first;
+ "Write the argument, aNumber as a long (four bytes).
+ If msbFlag is true, data is written most-significant byte first;
otherwise least first.
Notice that integers in the range -16r80000000 to +16rFFFFFFFF can be written
(i.e. both signed and unsigned int32 values can be written.
@@ -4459,29 +4459,29 @@
%{
int num;
union {
- char bytes[4];
- int intVal;
+ char bytes[4];
+ int intVal;
} u;
OBJ fp;
__INST(lastErrorNumber) = nil;
if (__isSmallInteger(aNumber)) {
- num = __intVal(aNumber);
+ num = __intVal(aNumber);
} else {
#if __POINTER_SIZE__ == 8
- // always more than 4-bytes
- goto badArg;
+ // always more than 4-bytes
+ goto badArg;
#else
- num = __longIntVal(aNumber);
- if (num == 0) {
- num = __signedLongIntVal(aNumber);
- if (num == 0) {
- /* bad arg or out-of-range integer
- * (handled by the fallBack code)
- */
- goto badArg;
- }
- }
+ num = __longIntVal(aNumber);
+ if (num == 0) {
+ num = __signedLongIntVal(aNumber);
+ if (num == 0) {
+ /* bad arg or out-of-range integer
+ * (handled by the fallBack code)
+ */
+ goto badArg;
+ }
+ }
#endif
}
@@ -4490,65 +4490,65 @@
|| (__INST(handleType) == @symbol(socketFilePointer))
|| (__INST(handleType) == @symbol(socketHandle))
|| (__INST(handleType) == @symbol(pipeFilePointer))) {
- if (((fp = __INST(handle)) != nil)
- && (__INST(mode) != @symbol(readonly))
- ) {
- int _buffered = (__INST(buffered) == true);
- FILEPOINTER f = __FILEVal(fp);
- int cnt;
-
- if (msbFlag == true) {
+ if (((fp = __INST(handle)) != nil)
+ && (__INST(mode) != @symbol(readonly))
+ ) {
+ int _buffered = (__INST(buffered) == true);
+ FILEPOINTER f = __FILEVal(fp);
+ int cnt;
+
+ if (msbFlag == true) {
#if defined(__MSBFIRST__)
- u.intVal = num;
+ u.intVal = num;
#else
- u.bytes[0] = (num >> 24) & 0xFF;
- u.bytes[1] = (num >> 16) & 0xFF;
- u.bytes[2] = (num >> 8) & 0xFF;
- u.bytes[3] = num & 0xFF;
+ u.bytes[0] = (num >> 24) & 0xFF;
+ u.bytes[1] = (num >> 16) & 0xFF;
+ u.bytes[2] = (num >> 8) & 0xFF;
+ u.bytes[3] = num & 0xFF;
#endif
- } else {
+ } else {
#if defined(__LSBFIRST__)
- u.intVal = num;
+ u.intVal = num;
#else
- u.bytes[3] = (num >> 24) & 0xFF;
- u.bytes[2] = (num >> 16) & 0xFF;
- u.bytes[1] = (num >> 8) & 0xFF;
- u.bytes[0] = num & 0xFF;
+ u.bytes[3] = (num >> 24) & 0xFF;
+ u.bytes[2] = (num >> 16) & 0xFF;
+ u.bytes[1] = (num >> 8) & 0xFF;
+ u.bytes[0] = num & 0xFF;
#endif
- }
-
- if (_buffered) {
- __WRITING__(f)
- }
- __WRITEBYTES__(cnt, f, u.bytes, 4, _buffered, __INST(handleType));
-
- if (cnt == 4) {
- if (__isSmallInteger(__INST(position))) {
- INT np = __intVal(__INST(position)) + 4;
- OBJ t;
-
- t = __MKINT(np); __INST(position) = t; __STORE(self, t);
- } else {
- __INST(position) = nil; /* i.e. do not know */
- }
- RETURN ( self );
- }
- __INST(position) = nil; /* i.e. do not know */
- error = __mkSmallInteger(__threadErrno);
- }
+ }
+
+ if (_buffered) {
+ __WRITING__(f)
+ }
+ __WRITEBYTES__(cnt, f, u.bytes, 4, _buffered, __INST(handleType));
+
+ if (cnt == 4) {
+ if (__isSmallInteger(__INST(position))) {
+ INT np = __intVal(__INST(position)) + 4;
+ OBJ t;
+
+ t = __MKINT(np); __INST(position) = t; __STORE(self, t);
+ } else {
+ __INST(position) = nil; /* i.e. do not know */
+ }
+ RETURN ( self );
+ }
+ __INST(position) = nil; /* i.e. do not know */
+ error = __mkSmallInteger(__threadErrno);
+ }
}
badArg: ;
%}.
handle isNil ifTrue:[self errorNotOpen. ^ self].
(mode == #readonly) ifTrue:[self errorReadOnly. ^ self].
error notNil ifTrue:[
- lastErrorNumber := error.
- self writeError:error.
- ^ self
+ lastErrorNumber := error.
+ self writeError:error.
+ ^ self
].
aNumber isInteger ifTrue:[
- ^ super nextPutInt32:aNumber MSB:msbFlag
+ ^ super nextPutInt32:aNumber MSB:msbFlag
].
self argumentMustBeInteger
!
@@ -4556,55 +4556,55 @@
nextPutInt32LSB:anIntegerOrCharacter
"do not remove.
See #patchByteOrderOptimizedMethods"
-
+
self nextPutInt32:anIntegerOrCharacter MSB:false
!
nextPutInt32MSB:anIntegerOrCharacter
"do not remove.
See #patchByteOrderOptimizedMethods"
-
+
self nextPutInt32:anIntegerOrCharacter MSB:true
!
nextPutInt32NATIVE:anInteger
- "Write the argument, anInteger as a long (four bytes) in native byte order.
+ "Write the argument, anInteger as a long (four bytes) in native byte order.
This is the CPU-specific byte order (LSB on x86, MSB on sparc, VAX and possibly on ARM).
Notice that integers in the range -16r80000000 to +16rFFFFFFFF can be written
(i.e. both signed and unsigned int32 values can be written.
Works in both binary and text modes.
Notice: this message should not be sent explicitly by ANY program.
- the following implementation replaces the code of either nextPutInt32MSB or LSB
- dynamically (see #initialize on the class side)"
+ the following implementation replaces the code of either nextPutInt32MSB or LSB
+ dynamically (see #initialize on the class side)"
|error|
%{
int num;
union {
- char bytes[4];
- int intVal;
+ char bytes[4];
+ int intVal;
} u;
OBJ fp;
__INST(lastErrorNumber) = nil;
if (__isSmallInteger(anInteger)) {
- num = __intVal(anInteger);
+ num = __intVal(anInteger);
} else {
#if __POINTER_SIZE__ == 8
- // always more than 4-bytes
- goto badArg;
+ // always more than 4-bytes
+ goto badArg;
#else
- num = __longIntVal(anInteger);
- if (num == 0) {
- num = __signedLongIntVal(anInteger);
- if (num == 0) {
- /* bad arg or out-of-range integer
- * (handled by the fallBack code)
- */
- goto badArg;
- }
- }
+ num = __longIntVal(anInteger);
+ if (num == 0) {
+ num = __signedLongIntVal(anInteger);
+ if (num == 0) {
+ /* bad arg or out-of-range integer
+ * (handled by the fallBack code)
+ */
+ goto badArg;
+ }
+ }
#endif
}
@@ -4613,33 +4613,33 @@
|| (__INST(handleType) == @symbol(socketFilePointer))
|| (__INST(handleType) == @symbol(socketHandle))
|| (__INST(handleType) == @symbol(pipeFilePointer))) {
- if (((fp = __INST(handle)) != nil)
- && (__INST(mode) != @symbol(readonly))
- ) {
- int _buffered = (__INST(buffered) == true);
- FILEPOINTER f = __FILEVal(fp);
- int cnt;
-
- u.intVal = num;
- if (_buffered) {
- __WRITING__(f)
- }
- __WRITEBYTES__(cnt, f, u.bytes, 4, _buffered, __INST(handleType));
-
- if (cnt == 4) {
- if (__isSmallInteger(__INST(position))) {
- INT np = __intVal(__INST(position)) + 4;
- OBJ t;
-
- t = __MKINT(np); __INST(position) = t; __STORE(self, t);
- } else {
- __INST(position) = nil; /* i.e. do not know */
- }
- RETURN ( self );
- }
- __INST(position) = nil; /* i.e. do not know */
- error = __mkSmallInteger(__threadErrno);
- }
+ if (((fp = __INST(handle)) != nil)
+ && (__INST(mode) != @symbol(readonly))
+ ) {
+ int _buffered = (__INST(buffered) == true);
+ FILEPOINTER f = __FILEVal(fp);
+ int cnt;
+
+ u.intVal = num;
+ if (_buffered) {
+ __WRITING__(f)
+ }
+ __WRITEBYTES__(cnt, f, u.bytes, 4, _buffered, __INST(handleType));
+
+ if (cnt == 4) {
+ if (__isSmallInteger(__INST(position))) {
+ INT np = __intVal(__INST(position)) + 4;
+ OBJ t;
+
+ t = __MKINT(np); __INST(position) = t; __STORE(self, t);
+ } else {
+ __INST(position) = nil; /* i.e. do not know */
+ }
+ RETURN ( self );
+ }
+ __INST(position) = nil; /* i.e. do not know */
+ error = __mkSmallInteger(__threadErrno);
+ }
}
badArg: ;
%}.
@@ -4685,74 +4685,74 @@
int rslt;
if (fp == nil) {
- error = @symbol(errorNotOpen);
- goto out;
+ error = @symbol(errorNotOpen);
+ goto out;
}
if (__INST(handleType) == @symbol(socketHandle)) {
- SOCKET sock = __FILEVal(fp);
-
- if (@global(FileOpenTrace) == true) {
- fprintf(stderr, "close socket [ExternalStream] %"_lx_"\n", (INT)sock);
- }
-
- // whether the close() will be successful or not - the handle is invalid now!
- __INST(handle) = nil;
- do {
-#ifdef WIN32
- rslt = __STX_WSA_NOINT_CALL1("closesocket", closesocket, sock);
+ SOCKET sock = __FILEVal(fp);
+
+ if (@global(FileOpenTrace) == true) {
+ fprintf(stderr, "close socket [ExternalStream] %"_lx_"\n", (INT)sock);
+ }
+
+ // whether the close() will be successful or not - the handle is invalid now!
+ __INST(handle) = nil;
+ do {
+#ifdef __win32__
+ rslt = __STX_WSA_NOINT_CALL1("closesocket", closesocket, sock);
#else
- rslt = close(sock);
+ rslt = close(sock);
#endif
- } while((rslt < 0) && (__threadErrno == EINTR));
+ } while((rslt < 0) && (__threadErrno == EINTR));
} else if ((__INST(handleType) == nil)
- || (__INST(handleType) == @symbol(filePointer))
- || (__INST(handleType) == @symbol(socketFilePointer))
- || (__INST(handleType) == @symbol(pipeFilePointer)))
+ || (__INST(handleType) == @symbol(filePointer))
+ || (__INST(handleType) == @symbol(socketFilePointer))
+ || (__INST(handleType) == @symbol(pipeFilePointer)))
{
- FILEPOINTER f = __FILEVal(fp);
-
- if (@global(FileOpenTrace) == true) {
- fprintf(stderr, "fclose [ExternalStream] %"_lx_"\n", (INT)f);
- }
- // whether the close() will be successful or not - the handle is invalid now!
- __INST(handle) = nil;
-
-#ifdef WIN32
- if (__INST(mode) != @symbol(readonly) && __INST(buffered) != false) {
- // do a fflush() first, so that fclose() doesn't block
- // we suspect, that EINTR causes problems in fclose()
- do {
- __threadErrno = 0;
- rslt = __STX_C_CALL1("fflush", fflush, f);
- } while((rslt < 0) && (__threadErrno == EINTR));
- }
- do {
- __threadErrno = 0;
- rslt = __STX_C_NOINT_CALL1("fclose", fclose, f);
- } while((rslt < 0) && (__threadErrno == EINTR));
+ FILEPOINTER f = __FILEVal(fp);
+
+ if (@global(FileOpenTrace) == true) {
+ fprintf(stderr, "fclose [ExternalStream] %"_lx_"\n", (INT)f);
+ }
+ // whether the close() will be successful or not - the handle is invalid now!
+ __INST(handle) = nil;
+
+#ifdef __win32__
+ if (__INST(mode) != @symbol(readonly) && __INST(buffered) != false) {
+ // do a fflush() first, so that fclose() doesn't block
+ // we suspect, that EINTR causes problems in fclose()
+ do {
+ __threadErrno = 0;
+ rslt = __STX_C_CALL1("fflush", fflush, f);
+ } while((rslt < 0) && (__threadErrno == EINTR));
+ }
+ do {
+ __threadErrno = 0;
+ rslt = __STX_C_NOINT_CALL1("fclose", fclose, f);
+ } while((rslt < 0) && (__threadErrno == EINTR));
#else
- // cg: the pre Nov2014 code always did the fclose interruptable;
- // I am not sure, if fclose is actually prepared to do this;
- // at least when only reading, this should not block, and we
- // should be ableto do it without being interruptable.
- // Must watch this - if it leads to blockings, change and think about it.
- if (__INST(mode) != @symbol(readonly)) {
- __BEGIN_INTERRUPTABLE__
- rslt = fclose(f);
- __END_INTERRUPTABLE__
- } else {
- rslt = fclose(f);
- }
+ // cg: the pre Nov2014 code always did the fclose interruptable;
+ // I am not sure, if fclose is actually prepared to do this;
+ // at least when only reading, this should not block, and we
+ // should be ableto do it without being interruptable.
+ // Must watch this - if it leads to blockings, change and think about it.
+ if (__INST(mode) != @symbol(readonly)) {
+ __BEGIN_INTERRUPTABLE__
+ rslt = fclose(f);
+ __END_INTERRUPTABLE__
+ } else {
+ rslt = fclose(f);
+ }
#endif
} else {
- error = @symbol(badHandleType);
- goto out;
+ error = @symbol(badHandleType);
+ goto out;
}
if (rslt < 0) {
- error = __mkSmallInteger(__threadErrno);
- goto out;
+ error = __mkSmallInteger(__threadErrno);
+ goto out;
}
RETURN (self);
@@ -4760,28 +4760,28 @@
%}.
error notNil ifTrue:[
- error == #errorNotOpen ifTrue:[
- self errorNotOpen.
- ].
- error isInteger ifTrue:[
- lastErrorNumber := error.
- mode == #readonly ifTrue:[
- self ioError:error.
- ] ifFalse:[
- self writeError:error.
- ].
- ^ self.
- ].
- self primitiveFailed:error.
- ^ self.
+ error == #errorNotOpen ifTrue:[
+ self errorNotOpen.
+ ].
+ error isInteger ifTrue:[
+ lastErrorNumber := error.
+ mode == #readonly ifTrue:[
+ self ioError:error.
+ ] ifFalse:[
+ self writeError:error.
+ ].
+ ^ self.
+ ].
+ self primitiveFailed:error.
+ ^ self.
].
"/ fallback for rel5
fp := handle.
fp notNil ifTrue:[
- handle := nil.
- self closeFile:fp
+ handle := nil.
+ self closeFile:fp
]
!
@@ -4811,13 +4811,13 @@
int fd = -2;
if (__isStringLike(openmode)) {
-#ifdef WIN32
+#ifdef __win32__
__stxWrapApiEnterCritical();
#endif
if (__isSmallInteger(aFileDescriptor)) {
fd = __intVal(aFileDescriptor);
}
-#ifdef WIN32
+#ifdef __win32__
else if (__isExternalAddressLike(aFileDescriptor)) {
fd = _open_osfhandle((long)__externalAddressVal(aFileDescriptor), O_BINARY);
if (fd < 0) {
@@ -4832,7 +4832,7 @@
}
#endif
f = (FILEPOINTER) fdopen(fd, (char *)__stringVal(openmode));
-#ifdef WIN32
+#ifdef __win32__
__stxWrapApiLeaveCritical();
#endif
if (f == NULL) {
@@ -4909,7 +4909,7 @@
OBJ fp;
if (__isStringLike(aPath) && __isStringLike(openModeString)) {
-#ifdef WIN32
+#ifdef __win32__
# if 1
f = fopen((char *) __stringVal(aPath), (char *) __stringVal(openModeString));
# else
@@ -5005,7 +5005,7 @@
if (!__isStringLike(openMode))
goto err;
-#ifdef WIN32
+#ifdef __win32__
__stxWrapApiEnterCritical();
if (__isExternalAddressLike(anIntegerOrExternalAddress) ) {
HANDLE __fileHandle = (HANDLE)__externalAddressVal(anIntegerOrExternalAddress);
@@ -5020,13 +5020,13 @@
if (__isSmallInteger(anIntegerOrExternalAddress)) {
fd = __smallIntegerVal(anIntegerOrExternalAddress);
} else {
-#ifdef WIN32
+#ifdef __win32__
__stxWrapApiLeaveCritical();
#endif
goto err;
}
f = fdopen(fd, __stringVal(openMode));
-#ifdef WIN32
+#ifdef __win32__
__stxWrapApiLeaveCritical();
#endif
if (f != NULL) {
@@ -5115,7 +5115,7 @@
fd := self fileDescriptor.
%{
-#ifdef WIN32
+#ifdef __win32__
int res = 1;
int success = 0;
@@ -5593,7 +5593,7 @@
* read ahead ...
*/
do {
-#ifdef WIN32
+#ifdef __win32__
# if 1
__READBYTE__(ret, f, &c, _buffered, __INST(handleType));
@@ -5602,7 +5602,7 @@
__READBYTE__(ret, f, &c, _buffered, __INST(handleType));
__END_INTERRUPTABLE__
# endif
-#else /* not WIN32 */
+#else /* not __win32__ */
__BEGIN_INTERRUPTABLE__
__READBYTE__(ret, f, &c, _buffered, __INST(handleType));
__END_INTERRUPTABLE__
@@ -5925,7 +5925,7 @@
cp = "\n"; len = 1;
}
}
-#ifdef WIN32
+#ifdef __win32__
if ((f == __win32_stdout()) || (f == __win32_stderr())) {
cnt = __win32_fwrite(cp, 1, len, f);
} else
@@ -5980,7 +5980,7 @@
if (__INST(mode) != @symbol(readonly)) {
if (_buffered) {
FILEPOINTER f = __FILEVal(fp);
-#ifdef WIN32
+#ifdef __win32__
if ((f == __win32_stdout()) || (f == __win32_stderr())) {
__win32_fflush(f);
} else {
@@ -5991,11 +5991,11 @@
rslt = __STX_C_CALL1("fflush", fflush, f);
} while((rslt < 0) && (__threadErrno == EINTR));
}
-#else /* ! WIN32 */
+#else /* ! __win32__ */
__BEGIN_INTERRUPTABLE__
FFLUSH(f);
__END_INTERRUPTABLE__
-#endif /* ! WIN32 */
+#endif /* ! __win32__ */
}
}
}
@@ -6074,7 +6074,7 @@
if (_buffered) {
__WRITING__(f)
}
-# ifdef WIN32
+# ifdef __win32__
if ((f == __win32_stdout()) || (f == __win32_stderr())) {
cnt = __win32_fwrite(buff, 1, nBytes, f);
} else
@@ -6247,7 +6247,7 @@
}
len = dp - buf;
-# ifdef WIN32
+# ifdef __win32__
if ((f == __win32_stdout()) || (f == __win32_stderr())) {
cnt = __win32_fwrite(buf, 1, len, f);
} else
@@ -6257,7 +6257,7 @@
}
free(buf);
} else { // No EOL conversion needed
-# ifdef WIN32
+# ifdef __win32__
if ((f == __win32_stdout()) || (f == __win32_stderr())) {
cnt = __win32_fwrite(stringP, 1, len, f);
} else
@@ -6279,7 +6279,7 @@
len = __byteArraySize(aCollection) - offs;
} else
goto out;
-# ifdef WIN32
+# ifdef __win32__
if ((f == __win32_stdout()) || (f == __win32_stderr())) {
cnt = __win32_fwrite(__stringVal(aCollection), 1, len, f);
} else
@@ -6446,7 +6446,7 @@
}
len = dp - buf;
-#ifdef WIN32
+#ifdef __win32__
if ((f == __win32_stdout()) || (f == __win32_stderr())) {
cnt = __win32_fwrite(buf, 1, len, f);
} else
@@ -6456,7 +6456,7 @@
}
free(buf);
} else { // No EOL conversion needed
-#ifdef WIN32
+#ifdef __win32__
if ((f == __win32_stdout()) || (f == __win32_stderr())) {
cnt = __win32_fwrite(stringP, 1, len, f);
} else
@@ -6486,7 +6486,7 @@
iStop = len;
len = iStop - iStart + 1;
offs += iStart - 1;
-#ifdef WIN32
+#ifdef __win32__
if ((f == __win32_stdout()) || (f == __win32_stderr())) {
cnt = __win32_fwrite(__stringVal(aCollection)+iStart-1, 1, len, f);
} else
@@ -6638,7 +6638,7 @@
}
if (extPtr) {
-# ifdef WIN32
+# ifdef __win32__
if ((f == __win32_stdout()) || (f == __win32_stderr())) {
cnt = __win32_fwrite(extPtr+offs, 1, len, f);
} else
@@ -6652,7 +6652,7 @@
* So we pass anObject, and the offset to the __WRITEBYTES_OBJ__ macro.
*/
offs += nInstBytes;
-# ifdef WIN32
+# ifdef __win32__
if ((f == __win32_stdout()) || (f == __win32_stderr())) {
cnt = __win32_fwrite((char *)anObject+offs, 1, len, f);
} else
@@ -6714,13 +6714,13 @@
self nextPutUtf16:aCharacter MSB:true
"
- (FileStream newTemporary
- nextPutUtf16:$B;
- nextPutUtf16:$Ä;
- nextPutUtf16:(Character codePoint:16r10CCCC);
- reset;
- binary;
- contents)
+ (FileStream newTemporary
+ nextPutUtf16:$B;
+ nextPutUtf16:$Ä;
+ nextPutUtf16:(Character codePoint:16r10CCCC);
+ reset;
+ binary;
+ contents)
"
!
@@ -6733,35 +6733,35 @@
codePoint := aCharacter codePoint.
(codePoint <= 16rD7FF
or:[codePoint >= 16rE000 and:[codePoint <= 16rFFFF]]) ifTrue:[
- self nextPutInt16:codePoint MSB:msb.
+ self nextPutInt16:codePoint MSB:msb.
] ifFalse:[codePoint <= 16r10FFFF ifTrue:[
- |highBits lowBits|
-
- codePoint := codePoint - 16r100000.
- highBits := codePoint bitShift:-10.
- lowBits := codePoint bitAnd:16r3FF.
- self nextPutInt16:highBits+16rD800 MSB:msb.
- self nextPutInt16:lowBits+16rDC00 MSB:msb.
+ |highBits lowBits|
+
+ codePoint := codePoint - 16r100000.
+ highBits := codePoint bitShift:-10.
+ lowBits := codePoint bitAnd:16r3FF.
+ self nextPutInt16:highBits+16rD800 MSB:msb.
+ self nextPutInt16:lowBits+16rDC00 MSB:msb.
] ifFalse:[
- EncodingError raiseWith:aCharacter errorString:'Character cannot be encoded as UTF-16'.
+ EncodingError raiseWith:aCharacter errorString:'Character cannot be encoded as UTF-16'.
]].
"
- (FileStream newTemporary
- nextPutUtf16:$B MSB:true;
- nextPutUtf16:$Ä MSB:true;
- nextPutUtf16:(Character codePoint:16r10CCCC) MSB:true;
- reset;
- binary;
- contents)
-
- (FileStream newTemporary
- nextPutUtf16:$B MSB:false;
- nextPutUtf16:$Ä MSB:false;
- nextPutUtf16:(Character codePoint:16r10CCCC) MSB:false;
- reset;
- binary;
- contents)
+ (FileStream newTemporary
+ nextPutUtf16:$B MSB:true;
+ nextPutUtf16:$Ä MSB:true;
+ nextPutUtf16:(Character codePoint:16r10CCCC) MSB:true;
+ reset;
+ binary;
+ contents)
+
+ (FileStream newTemporary
+ nextPutUtf16:$B MSB:false;
+ nextPutUtf16:$Ä MSB:false;
+ nextPutUtf16:(Character codePoint:16r10CCCC) MSB:false;
+ reset;
+ binary;
+ contents)
"
!
@@ -6804,7 +6804,7 @@
if (_buffered) {
__WRITING__(f)
}
-#ifdef WIN32
+#ifdef __win32__
if ((f == __win32_stdout()) || (f == __win32_stderr())) {
cnt = __win32_fwrite(&c, 1, 1, f);
} else