Merge jv
authorJan Vrany <jan.vrany@fit.cvut.cz>
Fri, 11 Mar 2016 10:06:30 +0000
branchjv
changeset 19332 9686fae7951b
parent 19331 59f77658de07 (current diff)
parent 19330 ecda55e8c18a (diff)
child 19333 b26c61158551
Merge
ExecutableFunction.st
ExternalBytes.st
ExternalLibraryFunction.st
Float.st
Integer.st
LargeInteger.st
LongFloat.st
ShortFloat.st
SmallInteger.st
--- a/ExecutableFunction.st	Thu Mar 10 08:13:13 2016 +0000
+++ b/ExecutableFunction.st	Fri Mar 11 10:06:30 2016 +0000
@@ -219,10 +219,12 @@
 
 hasCode
     "return true, if this codeObject has machinecode to execute."
-%{
+
+%{  /* NOCONTEXT */
     if (__INST(code_)) {
         RETURN (true);
     }
+    RETURN (false);
 %}.
     ^ false
 
--- a/ExternalBytes.st	Thu Mar 10 08:13:13 2016 +0000
+++ b/ExternalBytes.st	Fri Mar 11 10:06:30 2016 +0000
@@ -1314,7 +1314,7 @@
     unsigned int size = __intVal(__INST(size));
     unsigned char *endP;
 
-    if (cp == nil || size == 0) {
+    if (cp == NULL || size == 0) {
 	RETURN(false);
     }
 
--- a/ExternalLibraryFunction.st	Thu Mar 10 08:13:13 2016 +0000
+++ b/ExternalLibraryFunction.st	Fri Mar 11 10:06:30 2016 +0000
@@ -18,13 +18,14 @@
 	classVariableNames:'DLLPATH FLAG_VIRTUAL FLAG_NONVIRTUAL FLAG_OBJECTIVEC FLAG_ASYNC
 		FLAG_UNLIMITEDSTACK FLAG_RETVAL_IS_CONST CALLTYPE_MASK
 		CALLTYPE_API CALLTYPE_C CALLTYPE_OLE CALLTYPE_V8 CALLTYPE_V9
-		CALLTYPE_UNIX64 DllMapping'
+		CALLTYPE_UNIX64 DllMapping Verbose'
 	poolDictionaries:''
 	category:'System-Support'
 !
 
 !ExternalLibraryFunction primitiveDefinitions!
 %{
+#define VERBOSE
 
 #ifdef HAVE_FFI
 # include <ffi.h>
@@ -46,20 +47,20 @@
 #  define __get_ffi_type_void() &ffi_type_void
 #  define __get_ffi_type_pointer() &ffi_type_pointer
 # else
-extern ffi_type *__get_ffi_type_sint();
-extern ffi_type *__get_ffi_type_sint8();
-extern ffi_type *__get_ffi_type_sint16();
-extern ffi_type *__get_ffi_type_sint32();
-extern ffi_type *__get_ffi_type_sint64();
-extern ffi_type *__get_ffi_type_uint();
-extern ffi_type *__get_ffi_type_uint8();
-extern ffi_type *__get_ffi_type_uint16();
-extern ffi_type *__get_ffi_type_uint32();
-extern ffi_type *__get_ffi_type_uint64();
-extern ffi_type *__get_ffi_type_float();
-extern ffi_type *__get_ffi_type_double();
-extern ffi_type *__get_ffi_type_void();
-extern ffi_type *__get_ffi_type_pointer();
+   extern ffi_type *__get_ffi_type_sint();
+   extern ffi_type *__get_ffi_type_sint8();
+   extern ffi_type *__get_ffi_type_sint16();
+   extern ffi_type *__get_ffi_type_sint32();
+   extern ffi_type *__get_ffi_type_sint64();
+   extern ffi_type *__get_ffi_type_uint();
+   extern ffi_type *__get_ffi_type_uint8();
+   extern ffi_type *__get_ffi_type_uint16();
+   extern ffi_type *__get_ffi_type_uint32();
+   extern ffi_type *__get_ffi_type_uint64();
+   extern ffi_type *__get_ffi_type_float();
+   extern ffi_type *__get_ffi_type_double();
+   extern ffi_type *__get_ffi_type_void();
+   extern ffi_type *__get_ffi_type_pointer();
 # endif
 
 #endif
@@ -632,8 +633,7 @@
 !ExternalLibraryFunction methodsFor:'private'!
 
 adjustTypes
-
-    argumentTypes notNil ifTrue:[
+    argumentTypes notEmptyOrNil ifTrue:[
         argumentTypes := argumentTypes collect:[:argType | self ffiTypeSymbolForType:argType].
     ].
     returnType := self ffiTypeSymbolForType:returnType.
@@ -791,7 +791,12 @@
     aType == #lpstr           ifTrue:[^ #charPointer ].
     aType == #hresult         ifTrue:[^ #uint32 ].
     aType == #boolean         ifTrue:[^ #bool ].
-    aType == #ulongReturn     ifTrue:[^ #uint32 ].    "/ TODO - care for 64bit machines
+    "/ care for 64bit machines
+    ExternalAddress pointerSize == 8 ifTrue:[
+	aType == #ulongReturn     ifTrue:[^ #uint64 ].
+    ] ifFalse:[
+	aType == #ulongReturn     ifTrue:[^ #uint32 ].
+    ].
     aType == #none            ifTrue:[^ #void ].
     aType == #struct          ifTrue:[^ #pointer ].
     aType == #structIn        ifTrue:[^ #pointer ].
@@ -886,36 +891,36 @@
     virtual := self isVirtualCPP.
     objectiveC := self isObjectiveC.
     (virtual "or:[self isNonVirtualCPP]") ifTrue:[
-        aReceiverOrNil isNil ifTrue:[
-            "/ must have a c++ object instance
-            self primitiveFailed.
-        ].
+	aReceiverOrNil isNil ifTrue:[
+	    "/ must have a c++ object instance
+	    self primitiveFailed.
+	].
 
-        "/ and it must be a kind of ExternalStructure !!
-        (aReceiverOrNil isKindOf:ExternalStructure) ifFalse:[
-            self primitiveFailed.
-        ].
-        virtual ifTrue:[
-            vtOffset := name.
-            (vtOffset between:0 and:10000) ifFalse:[
-                self primitiveFailed.
-            ]
-        ].
+	"/ and it must be a kind of ExternalStructure !!
+	(aReceiverOrNil isKindOf:ExternalStructure) ifFalse:[
+	    self primitiveFailed.
+	].
+	virtual ifTrue:[
+	    vtOffset := name.
+	    (vtOffset between:0 and:10000) ifFalse:[
+		self primitiveFailed.
+	    ]
+	].
     ] ifFalse:[
-        objectiveC ifTrue:[
-            aReceiverOrNil isNil ifTrue:[
-                "/ must have an objective-c object instance
-                self primitiveFailed.
-            ].
-            (aReceiverOrNil isObjectiveCObject) ifFalse:[
-                self primitiveFailed
-            ]
-        ] ifFalse:[
-            aReceiverOrNil notNil ifTrue:[
-                "/ must NOT have a c++/objectiveC object instance
-                self primitiveFailed.
-            ]
-        ].
+	objectiveC ifTrue:[
+	    aReceiverOrNil isNil ifTrue:[
+		"/ must have an objective-c object instance
+		self primitiveFailed.
+	    ].
+	    (aReceiverOrNil isObjectiveCObject) ifFalse:[
+		self primitiveFailed
+	    ]
+	] ifFalse:[
+	    aReceiverOrNil notNil ifTrue:[
+		"/ must NOT have a c++/objectiveC object instance
+		self primitiveFailed.
+	    ]
+	].
     ].
     async := self isAsync.
     unlimitedStack := self isUnlimitedStack.
@@ -940,17 +945,17 @@
     ffi_type *__returnType = NULL;
 
     union u {
-        INT iVal;
-        float fVal;
-        double dVal;
-        void *pointerVal;
+	INT iVal;
+	float fVal;
+	double dVal;
+	void *pointerVal;
 # if defined(HAS_LONGLONG)
-        long long longLongVal;
+	long long longLongVal;
 # else
 #  ifdef HAS_INT64
-        __int64__ longLongVal;
+	__int64__ longLongVal;
 #  else
-        struct ll { long low; long hi; } longLongVal;
+	struct ll { long low; long hi; } longLongVal;
 #  endif
 # endif
     };
@@ -969,29 +974,29 @@
 
 #   define __FAIL__(fcode) \
     { \
-        failureCode = fcode; goto getOutOfHere; \
+	failureCode = fcode; goto getOutOfHere; \
     }
 
     if (argumentsOrNil == nil) {
-        __numArgs = 0;
+	__numArgs = 0;
     } else if (__isArray(argumentsOrNil)) {
-        __numArgs = __arraySize(argumentsOrNil);
+	__numArgs = __arraySize(argumentsOrNil);
     } else {
-        __FAIL__(@symbol(BadArgumentVector))
+	__FAIL__(@symbol(BadArgumentVector))
     }
     if (argTypeSymbols == nil) {
-        __numArgsWanted = 0;
+	__numArgsWanted = 0;
     } else if (__isArray(argTypeSymbols)) {
-        __numArgsWanted = __arraySize(argTypeSymbols);
+	__numArgsWanted = __arraySize(argTypeSymbols);
     } else {
-        __FAIL__(@symbol(BadArgumentTypeVector))
+	__FAIL__(@symbol(BadArgumentTypeVector))
     }
 
     if (__numArgs != __numArgsWanted) {
-        __FAIL__(@symbol(ArgumentCountMismatch))
+	__FAIL__(@symbol(ArgumentCountMismatch))
     }
     if (__numArgs > MAX_ARGS) {
-        __FAIL__(@symbol(TooManyArguments))
+	__FAIL__(@symbol(TooManyArguments))
     }
 
     /*
@@ -1000,130 +1005,134 @@
     __returnValuePointer = &__returnValue;
 
     if (returnTypeSymbol == @symbol(voidPointer)) {
-        returnTypeSymbol = @symbol(handle);
+	returnTypeSymbol = @symbol(handle);
     }
 
     if (returnTypeSymbol == @symbol(int)) {
-        __returnType = __get_ffi_type_sint();
+	__returnType = __get_ffi_type_sint();
     } else if (returnTypeSymbol == @symbol(uint)) {
-        __returnType = __get_ffi_type_uint();
+	__returnType = __get_ffi_type_uint();
     } else if (returnTypeSymbol == @symbol(uint8)) {
-        __returnType = __get_ffi_type_uint8();
+	__returnType = __get_ffi_type_uint8();
     } else if (returnTypeSymbol == @symbol(uint16)) {
-        __returnType = __get_ffi_type_uint16();
+	__returnType = __get_ffi_type_uint16();
     } else if (returnTypeSymbol == @symbol(uint32)) {
-        __returnType = __get_ffi_type_uint32();
+	__returnType = __get_ffi_type_uint32();
     } else if (returnTypeSymbol == @symbol(uint64)) {
-        __returnType = __get_ffi_type_uint64();
+	__returnType = __get_ffi_type_uint64();
 
     } else if (returnTypeSymbol == @symbol(sint)) {
-        __returnType = __get_ffi_type_sint();
+	__returnType = __get_ffi_type_sint();
     } else if (returnTypeSymbol == @symbol(sint8)) {
-        __returnType = __get_ffi_type_sint8();
+	__returnType = __get_ffi_type_sint8();
     } else if (returnTypeSymbol == @symbol(sint16)) {
-        __returnType = __get_ffi_type_sint16();
+	__returnType = __get_ffi_type_sint16();
     } else if (returnTypeSymbol == @symbol(sint32)) {
-        __returnType = __get_ffi_type_sint32();
+	__returnType = __get_ffi_type_sint32();
     } else if (returnTypeSymbol == @symbol(sint64)) {
-        __returnType = __get_ffi_type_sint64();
+	__returnType = __get_ffi_type_sint64();
 
     } else if (returnTypeSymbol == @symbol(long)) {
-        if (sizeof(long) == 4) {
-           returnTypeSymbol = @symbol(sint32);
-           __returnType = __get_ffi_type_sint32();
-        } else if (sizeof(long) == 8) {
-           returnTypeSymbol = @symbol(sint64);
-           __returnType = __get_ffi_type_sint64();
-        } else {
-            __FAIL__(@symbol(UnknownReturnType))
-        }
+	if (sizeof(long) == 4) {
+	   returnTypeSymbol = @symbol(sint32);
+	   __returnType = __get_ffi_type_sint32();
+	} else if (sizeof(long) == 8) {
+	   returnTypeSymbol = @symbol(sint64);
+	   __returnType = __get_ffi_type_sint64();
+	} else {
+	    __FAIL__(@symbol(UnknownReturnType))
+	}
 
     } else if (returnTypeSymbol == @symbol(ulong)) {
-        if (sizeof(long) == 4) {
-           returnTypeSymbol = @symbol(uint32);
-           __returnType = __get_ffi_type_uint32();
-        }else if (sizeof(long) == 8) {
-           returnTypeSymbol = @symbol(uint64);
-           __returnType = __get_ffi_type_uint64();
-        } else {
-            __FAIL__(@symbol(UnknownReturnType))
-        }
+	if (sizeof(long) == 4) {
+	   returnTypeSymbol = @symbol(uint32);
+	   __returnType = __get_ffi_type_uint32();
+	}else if (sizeof(long) == 8) {
+	   returnTypeSymbol = @symbol(uint64);
+	   __returnType = __get_ffi_type_uint64();
+	} else {
+	    __FAIL__(@symbol(UnknownReturnType))
+	}
 
     } else if (returnTypeSymbol == @symbol(bool)) {
-        __returnType = __get_ffi_type_uint();
+	__returnType = __get_ffi_type_uint();
 
     } else if (returnTypeSymbol == @symbol(float)) {
-        __returnType = __get_ffi_type_float();
+	__returnType = __get_ffi_type_float();
     } else if (returnTypeSymbol == @symbol(double)) {
-        __returnType = __get_ffi_type_double();
+	__returnType = __get_ffi_type_double();
 
     } else if (returnTypeSymbol == @symbol(void)) {
-        __returnType = __get_ffi_type_void();
-        __returnValuePointer = NULL;
+	__returnType = __get_ffi_type_void();
+	__returnValuePointer = NULL;
     } else if ((returnTypeSymbol == @symbol(pointer))
-               || (returnTypeSymbol == @symbol(handle))
-               || (returnTypeSymbol == @symbol(charPointer))
-               || (returnTypeSymbol == @symbol(bytePointer))
-               || (returnTypeSymbol == @symbol(floatPointer))
-               || (returnTypeSymbol == @symbol(doublePointer))
-               || (returnTypeSymbol == @symbol(intPointer))
-               || (returnTypeSymbol == @symbol(shortPointer))
-               || (returnTypeSymbol == @symbol(wcharPointer))) {
-        __returnType = __get_ffi_type_pointer();
+	       || (returnTypeSymbol == @symbol(handle))
+	       || (returnTypeSymbol == @symbol(charPointer))
+	       || (returnTypeSymbol == @symbol(bytePointer))
+	       || (returnTypeSymbol == @symbol(floatPointer))
+	       || (returnTypeSymbol == @symbol(doublePointer))
+	       || (returnTypeSymbol == @symbol(intPointer))
+	       || (returnTypeSymbol == @symbol(shortPointer))
+	       || (returnTypeSymbol == @symbol(wcharPointer))) {
+	__returnType = __get_ffi_type_pointer();
     } else {
-        if (__isSymbol(returnTypeSymbol)
-         && ((returnValueClass = __GLOBAL_GET(returnTypeSymbol)) != nil)) {
-            if (! __isBehaviorLike(returnValueClass)) {
-                __FAIL__(@symbol(NonBehaviorReturnType))
-            }
-            if (! __qIsSubclassOfExternalAddress(returnValueClass)) {
-                __FAIL__(@symbol(NonExternalAddressReturnType))
-            }
-            __returnType = __get_ffi_type_pointer();
-            returnTypeSymbol = @symbol(pointer);
-        } else {
-            __FAIL__(@symbol(UnknownReturnType))
-        }
+	if (__isSymbol(returnTypeSymbol)
+	 && ((returnValueClass = __GLOBAL_GET(returnTypeSymbol)) != nil)) {
+	    if (! __isBehaviorLike(returnValueClass)) {
+		__FAIL__(@symbol(NonBehaviorReturnType))
+	    }
+	    if (! __qIsSubclassOfExternalAddress(returnValueClass)) {
+		__FAIL__(@symbol(NonExternalAddressReturnType))
+	    }
+	    __returnType = __get_ffi_type_pointer();
+	    returnTypeSymbol = @symbol(pointer);
+	} else {
+	    __FAIL__(@symbol(UnknownReturnType))
+	}
     }
 
     /*
      * validate the c++ object
      */
     if (aReceiverOrNil != nil) {
-        struct cPlusPlusInstance {
-            void **vTable;
-        };
-        struct cPlusPlusInstance *inst;
+	struct cPlusPlusInstance {
+	    void **vTable;
+	};
+	struct cPlusPlusInstance *inst;
 
-        if (__isExternalAddressLike(aReceiverOrNil)) {
-            inst = (void *)(__externalAddressVal(aReceiverOrNil));
-        } else if (__isExternalBytesLike(aReceiverOrNil)) {
-            inst = (void *)(__externalBytesVal(aReceiverOrNil));
-        } else {
-            __FAIL__(@symbol(InvalidInstance))
-        }
-        __argValues[0].pointerVal = inst;
-        __argValuePointersIncludingThis[0] = &(__argValues[0]);
-        __argTypes[0] = __get_ffi_type_pointer();
+	if (__isExternalAddressLike(aReceiverOrNil)) {
+	    inst = (void *)(__externalAddressVal(aReceiverOrNil));
+	} else if (__isExternalBytesLike(aReceiverOrNil)) {
+	    inst = (void *)(__externalBytesVal(aReceiverOrNil));
+	} else {
+	    __FAIL__(@symbol(InvalidInstance))
+	}
+	__argValues[0].pointerVal = inst;
+	__argValuePointersIncludingThis[0] = &(__argValues[0]);
+	__argTypes[0] = __get_ffi_type_pointer();
 
-        __argValuePointers = &__argValuePointersIncludingThis[1];
-        __argTypes = &__argTypesIncludingThis[1];
-        __argValues = &__argValuesIncludingThis[1];
-        __numArgsIncludingThis = __numArgs + 1;
+	__argValuePointers = &__argValuePointersIncludingThis[1];
+	__argTypes = &__argTypesIncludingThis[1];
+	__argValues = &__argValuesIncludingThis[1];
+	__numArgsIncludingThis = __numArgs + 1;
 
-        if (virtual == true) {
-            if (! __isSmallInteger(vtOffset)) {
-                __FAIL__(@symbol(InvalidVTableIndex))
-            }
-            codeAddress = inst->vTable[__intVal(vtOffset)];
+	if (virtual == true) {
+	    if (! __isSmallInteger(vtOffset)) {
+		__FAIL__(@symbol(InvalidVTableIndex))
+	    }
+	    codeAddress = inst->vTable[__intVal(vtOffset)];
 # ifdef VERBOSE
-            printf("virtual codeAddress: %x\n", codeAddress);
+	    if (@global(Verbose) == true) {
+		printf("virtual codeAddress: %"_lx_"\n", (INT)codeAddress);
+	    }
 # endif
-        }
+	}
     } else {
-        __numArgsIncludingThis = __numArgs;
+	__numArgsIncludingThis = __numArgs;
 # ifdef VERBOSE
-        printf("codeAddress: %x\n", codeAddress);
+	if (@global(Verbose) == true) {
+	    printf("codeAddress: %"_lx_"\n", (INT)codeAddress);
+	}
 # endif
     }
 
@@ -1131,125 +1140,125 @@
      * validate all arg types and setup arg-buffers
      */
     for (i=0; i<__numArgs; i++) {
-        ffi_type *thisType;
-        void *argValuePtr;
-        OBJ typeSymbol;
-        OBJ arg;
+	ffi_type *thisType;
+	void *argValuePtr;
+	OBJ typeSymbol;
+	OBJ arg;
 
-        failureInfo = __mkSmallInteger(i+1);   /* in case there is one */
+	failureInfo = __mkSmallInteger(i+1);   /* in case there is one */
 
-        typeSymbol = __ArrayInstPtr(argTypeSymbols)->a_element[i];
-        arg = __ArrayInstPtr(argumentsOrNil)->a_element[i];
+	typeSymbol = __ArrayInstPtr(argTypeSymbols)->a_element[i];
+	arg = __ArrayInstPtr(argumentsOrNil)->a_element[i];
 
-        if (typeSymbol == @symbol(handle)) {
-            typeSymbol = @symbol(pointer);
-        } else if (typeSymbol == @symbol(voidPointer)) {
-            typeSymbol = @symbol(pointer);
-        }
+	if (typeSymbol == @symbol(handle)) {
+	    typeSymbol = @symbol(pointer);
+	} else if (typeSymbol == @symbol(voidPointer)) {
+	    typeSymbol = @symbol(pointer);
+	}
 
-        if (typeSymbol == @symbol(long)) {
-            if (sizeof(long) == sizeof(int)) {
-                typeSymbol = @symbol(sint);
-            } else {
-                if (sizeof(long) == 4) {
-                    typeSymbol = @symbol(sint32);
-                } else if (sizeof(long) == 8) {
-                    typeSymbol = @symbol(sint64);
-                }
-            }
-        }
-        if (typeSymbol == @symbol(ulong)) {
-            if (sizeof(unsigned long) == sizeof(unsigned int)) {
-                typeSymbol = @symbol(uint);
-            } else {
-                if (sizeof(long) == 4) {
-                    typeSymbol = @symbol(uint32);
-                } else if (sizeof(long) == 8) {
-                    typeSymbol = @symbol(uint64);
-                }
-            }
-        }
+	if (typeSymbol == @symbol(long)) {
+	    if (sizeof(long) == sizeof(int)) {
+		typeSymbol = @symbol(sint);
+	    } else {
+		if (sizeof(long) == 4) {
+		    typeSymbol = @symbol(sint32);
+		} else if (sizeof(long) == 8) {
+		    typeSymbol = @symbol(sint64);
+		}
+	    }
+	}
+	if (typeSymbol == @symbol(ulong)) {
+	    if (sizeof(unsigned long) == sizeof(unsigned int)) {
+		typeSymbol = @symbol(uint);
+	    } else {
+		if (sizeof(long) == 4) {
+		    typeSymbol = @symbol(uint32);
+		} else if (sizeof(long) == 8) {
+		    typeSymbol = @symbol(uint64);
+		}
+	    }
+	}
 
-        if (typeSymbol == @symbol(int) || typeSymbol == @symbol(sint)) {
-            thisType = __get_ffi_type_sint();
-            if (__isSmallInteger(arg)) {
-                __argValues[i].iVal = __intVal(arg);
-            } else {
-                __argValues[i].iVal = __signedLongIntVal(arg);
-                if (__argValues[i].iVal == 0) {
-                    __FAIL__(@symbol(InvalidArgument))
-                }
-            }
-            argValuePtr = &(__argValues[i].iVal);
+	if (typeSymbol == @symbol(int) || typeSymbol == @symbol(sint)) {
+	    thisType = __get_ffi_type_sint();
+	    if (__isSmallInteger(arg)) {
+		__argValues[i].iVal = __intVal(arg);
+	    } else {
+		__argValues[i].iVal = __signedLongIntVal(arg);
+		if (__argValues[i].iVal == 0) {
+		    __FAIL__(@symbol(InvalidArgument))
+		}
+	    }
+	    argValuePtr = &(__argValues[i].iVal);
 
-        } else if (typeSymbol == @symbol(uint)) {
-            thisType = __get_ffi_type_uint();
+	} else if (typeSymbol == @symbol(uint)) {
+	    thisType = __get_ffi_type_uint();
 
-            if (__isSmallInteger(arg)) {
-                __argValues[i].iVal = __intVal(arg);
-            } else {
-                __argValues[i].iVal = __unsignedLongIntVal(arg);
-                if (__argValues[i].iVal == 0) {
-                    __FAIL__(@symbol(InvalidArgument))
-                }
-            }
-            argValuePtr = &(__argValues[i].iVal);
+	    if (__isSmallInteger(arg)) {
+		__argValues[i].iVal = __intVal(arg);
+	    } else {
+		__argValues[i].iVal = __unsignedLongIntVal(arg);
+		if (__argValues[i].iVal == 0) {
+		    __FAIL__(@symbol(InvalidArgument))
+		}
+	    }
+	    argValuePtr = &(__argValues[i].iVal);
 
-        } else if (typeSymbol == @symbol(uint8)) {
-            thisType = __get_ffi_type_uint8();
-            if (! __isSmallInteger(arg)) {
-                __FAIL__(@symbol(InvalidArgument))
-            }
-            __argValues[i].iVal = __intVal(arg);
-            if (((unsigned)(__argValues[i].iVal)) > 0xFF) {
-                __FAIL__(@symbol(InvalidArgument))
-            }
-            argValuePtr = &(__argValues[i].iVal);
+	} else if (typeSymbol == @symbol(uint8)) {
+	    thisType = __get_ffi_type_uint8();
+	    if (! __isSmallInteger(arg)) {
+		__FAIL__(@symbol(InvalidArgument))
+	    }
+	    __argValues[i].iVal = __intVal(arg);
+	    if (((unsigned)(__argValues[i].iVal)) > 0xFF) {
+		__FAIL__(@symbol(InvalidArgument))
+	    }
+	    argValuePtr = &(__argValues[i].iVal);
 
-        } else if (typeSymbol == @symbol(sint8)) {
-            thisType = __get_ffi_type_sint8();
-            if (! __isSmallInteger(arg)) {
-                __FAIL__(@symbol(InvalidArgument))
-            }
-            __argValues[i].iVal = __intVal(arg);
-            if (((__argValues[i].iVal) < -0x80) || ((__argValues[i].iVal) > 0x7F))  {
-                __FAIL__(@symbol(InvalidArgument))
-            }
-            argValuePtr = &(__argValues[i].iVal);
+	} else if (typeSymbol == @symbol(sint8)) {
+	    thisType = __get_ffi_type_sint8();
+	    if (! __isSmallInteger(arg)) {
+		__FAIL__(@symbol(InvalidArgument))
+	    }
+	    __argValues[i].iVal = __intVal(arg);
+	    if (((__argValues[i].iVal) < -0x80) || ((__argValues[i].iVal) > 0x7F))  {
+		__FAIL__(@symbol(InvalidArgument))
+	    }
+	    argValuePtr = &(__argValues[i].iVal);
 
-        } else if (typeSymbol == @symbol(uint16)) {
-            thisType = __get_ffi_type_uint16();
-            if (! __isSmallInteger(arg)) {
-                __FAIL__(@symbol(InvalidArgument))
-            }
-            __argValues[i].iVal = __intVal(arg);
-            if (((unsigned)(__argValues[i].iVal)) > 0xFFFF) {
-                __FAIL__(@symbol(InvalidArgument))
-            }
-            argValuePtr = &(__argValues[i].iVal);
+	} else if (typeSymbol == @symbol(uint16)) {
+	    thisType = __get_ffi_type_uint16();
+	    if (! __isSmallInteger(arg)) {
+		__FAIL__(@symbol(InvalidArgument))
+	    }
+	    __argValues[i].iVal = __intVal(arg);
+	    if (((unsigned)(__argValues[i].iVal)) > 0xFFFF) {
+		__FAIL__(@symbol(InvalidArgument))
+	    }
+	    argValuePtr = &(__argValues[i].iVal);
 
-        } else if (typeSymbol == @symbol(sint16)) {
-            thisType = __get_ffi_type_sint16();
-            if (! __isSmallInteger(arg)) {
-                __FAIL__(@symbol(InvalidArgument))
-            }
-            __argValues[i].iVal = __intVal(arg);
-            if (((__argValues[i].iVal) < -0x8000) || ((__argValues[i].iVal) > 0x7FFF))  {
-                __FAIL__(@symbol(InvalidArgument))
-            }
-            argValuePtr = &(__argValues[i].iVal);
+	} else if (typeSymbol == @symbol(sint16)) {
+	    thisType = __get_ffi_type_sint16();
+	    if (! __isSmallInteger(arg)) {
+		__FAIL__(@symbol(InvalidArgument))
+	    }
+	    __argValues[i].iVal = __intVal(arg);
+	    if (((__argValues[i].iVal) < -0x8000) || ((__argValues[i].iVal) > 0x7FFF))  {
+		__FAIL__(@symbol(InvalidArgument))
+	    }
+	    argValuePtr = &(__argValues[i].iVal);
 
-        } else if ((typeSymbol == @symbol(uint32)) || (typeSymbol == @symbol(sint32))) {
-            thisType = __get_ffi_type_uint32();
-            if (__isSmallInteger(arg)) {
-                __argValues[i].iVal = __intVal(arg);
-            } else {
-                __argValues[i].iVal = __unsignedLongIntVal(arg);
-                if (__argValues[i].iVal == 0) {
-                    __FAIL__(@symbol(InvalidArgument))
-                }
-            }
-            argValuePtr = &(__argValues[i].iVal);
+	} else if ((typeSymbol == @symbol(uint32)) || (typeSymbol == @symbol(sint32))) {
+	    thisType = __get_ffi_type_uint32();
+	    if (__isSmallInteger(arg)) {
+		__argValues[i].iVal = __intVal(arg);
+	    } else {
+		__argValues[i].iVal = __unsignedLongIntVal(arg);
+		if (__argValues[i].iVal == 0) {
+		    __FAIL__(@symbol(InvalidArgument))
+		}
+	    }
+	    argValuePtr = &(__argValues[i].iVal);
 
         } else if (typeSymbol == @symbol(uint64)) {
             thisType = __get_ffi_type_uint64();
@@ -1273,219 +1282,221 @@
             }
             argValuePtr = &(__argValues[i].longLongVal);
             
-        } else if (typeSymbol == @symbol(float)) {
-            thisType = __get_ffi_type_float();
-            if (__isSmallInteger(arg)) {
-                __argValues[i].fVal = (float)(__intVal(arg));
-            } else if (__isFloat(arg)) {
-                __argValues[i].fVal = (float)(__floatVal(arg));
-            } else if (__isShortFloat(arg)) {
-                __argValues[i].fVal = (float)(__shortFloatVal(arg));
-            } else {
-                __FAIL__(@symbol(InvalidArgument))
-            }
-            argValuePtr = &(__argValues[i].fVal);
+	} else if (typeSymbol == @symbol(float)) {
+	    thisType = __get_ffi_type_float();
+	    if (__isSmallInteger(arg)) {
+		__argValues[i].fVal = (float)(__intVal(arg));
+	    } else if (__isFloat(arg)) {
+		__argValues[i].fVal = (float)(__floatVal(arg));
+	    } else if (__isShortFloat(arg)) {
+		__argValues[i].fVal = (float)(__shortFloatVal(arg));
+	    } else {
+		__FAIL__(@symbol(InvalidArgument))
+	    }
+	    argValuePtr = &(__argValues[i].fVal);
 
-        } else if (typeSymbol == @symbol(double)) {
-            thisType = __get_ffi_type_double();
-            if (__isSmallInteger(arg)) {
-                __argValues[i].dVal = (double)(__intVal(arg));
-            } else if (__isFloat(arg)) {
-                __argValues[i].dVal = (double)(__floatVal(arg));
-            } else if (__isShortFloat(arg)) {
-                __argValues[i].dVal = (double)(__shortFloatVal(arg));
-            } else {
-                __FAIL__(@symbol(InvalidArgument))
-            }
-            argValuePtr = &(__argValues[i].dVal);
+	} else if (typeSymbol == @symbol(double)) {
+	    thisType = __get_ffi_type_double();
+	    if (__isSmallInteger(arg)) {
+		__argValues[i].dVal = (double)(__intVal(arg));
+	    } else if (__isFloat(arg)) {
+		__argValues[i].dVal = (double)(__floatVal(arg));
+	    } else if (__isShortFloat(arg)) {
+		__argValues[i].dVal = (double)(__shortFloatVal(arg));
+	    } else {
+		__FAIL__(@symbol(InvalidArgument))
+	    }
+	    argValuePtr = &(__argValues[i].dVal);
 
-        } else if (typeSymbol == @symbol(void)) {
-            thisType = __get_ffi_type_void();
-            argValuePtr = &null;
+	} else if (typeSymbol == @symbol(void)) {
+	    thisType = __get_ffi_type_void();
+	    argValuePtr = &null;
 
-        } else if (typeSymbol == @symbol(charPointer)) {
-            thisType = __get_ffi_type_pointer();
-            if (__isStringLike(arg)) {
-                if (async == true) goto badArgForAsyncCall;
-                __argValues[i].pointerVal = (void *)(__stringVal(arg));
-            } else if (__isBytes(arg)) {
-                if (async == true) goto badArgForAsyncCall;
-                __argValues[i].pointerVal = (void *)(__byteArrayVal(arg));
-            } else if (__isExternalAddressLike(arg)) {
-                __argValues[i].pointerVal = (void *)(__externalAddressVal(arg));
-            } else if (__isExternalBytesLike(arg)) {
-                __argValues[i].pointerVal = (void *)(__externalBytesVal(arg));
-            } else {
-                if (arg == nil) {
-                    __argValues[i].pointerVal = (void *)0;
-                } else {
-                    __FAIL__(@symbol(InvalidArgument))
-                }
-            }
-            argValuePtr = &(__argValues[i].pointerVal);;
+	} else if (typeSymbol == @symbol(charPointer)) {
+	    thisType = __get_ffi_type_pointer();
+	    if (__isStringLike(arg)) {
+		if (async == true) goto badArgForAsyncCall;
+		__argValues[i].pointerVal = (void *)(__stringVal(arg));
+	    } else if (__isBytes(arg)) {
+		if (async == true) goto badArgForAsyncCall;
+		__argValues[i].pointerVal = (void *)(__byteArrayVal(arg));
+	    } else if (__isExternalAddressLike(arg)) {
+		__argValues[i].pointerVal = (void *)(__externalAddressVal(arg));
+	    } else if (__isExternalBytesLike(arg)) {
+		__argValues[i].pointerVal = (void *)(__externalBytesVal(arg));
+	    } else {
+		if (arg == nil) {
+		    __argValues[i].pointerVal = (void *)0;
+		} else {
+		    __FAIL__(@symbol(InvalidArgument))
+		}
+	    }
+	    argValuePtr = &(__argValues[i].pointerVal);;
 
-        } else if (typeSymbol == @symbol(wcharPointer)) {
-            thisType = __get_ffi_type_pointer();
-            if (__isUnicode16String(arg)) {
-                if (async == true) goto badArgForAsyncCall;
-                __argValues[i].pointerVal = (void *)(__unicode16StringVal(arg));
-            } else if (__isBytes(arg)) {
-                if (async == true) goto badArgForAsyncCall;
-                __argValues[i].pointerVal = (void *)(__byteArrayVal(arg));
-            } else if (__isExternalAddressLike(arg)) {
-                __argValues[i].pointerVal = (void *)(__externalAddressVal(arg));
-            } else if (__isExternalBytesLike(arg)) {
-                __argValues[i].pointerVal = (void *)(__externalBytesVal(arg));
-            } else {
-                if (arg == nil) {
-                    __argValues[i].pointerVal = (void *)0;
-                } else {
-                    __FAIL__(@symbol(InvalidArgument))
-                }
-            }
-            argValuePtr = &(__argValues[i].pointerVal);;
+	} else if (typeSymbol == @symbol(wcharPointer)) {
+	    thisType = __get_ffi_type_pointer();
+	    if (__isUnicode16String(arg)) {
+		if (async == true) goto badArgForAsyncCall;
+		__argValues[i].pointerVal = (void *)(__unicode16StringVal(arg));
+	    } else if (__isBytes(arg)) {
+		if (async == true) goto badArgForAsyncCall;
+		__argValues[i].pointerVal = (void *)(__byteArrayVal(arg));
+	    } else if (__isExternalAddressLike(arg)) {
+		__argValues[i].pointerVal = (void *)(__externalAddressVal(arg));
+	    } else if (__isExternalBytesLike(arg)) {
+		__argValues[i].pointerVal = (void *)(__externalBytesVal(arg));
+	    } else {
+		if (arg == nil) {
+		    __argValues[i].pointerVal = (void *)0;
+		} else {
+		    __FAIL__(@symbol(InvalidArgument))
+		}
+	    }
+	    argValuePtr = &(__argValues[i].pointerVal);;
 
-        } else if (typeSymbol == @symbol(floatPointer)) {
-            thisType = __get_ffi_type_pointer();
-            if (__isBytes(arg)) {
-                if (async == true) goto badArgForAsyncCall;
-                __argValues[i].pointerVal = (void *)(__byteArrayVal(arg));
-            } else if (__isExternalAddressLike(arg)) {
-                __argValues[i].pointerVal = (void *)(__externalAddressVal(arg));
-            } else if (__isExternalBytesLike(arg)) {
-                __argValues[i].pointerVal = (void *)(__externalBytesVal(arg));
-            } else if (__isFloats(arg)) {
-                char *p = (char *)(__FloatArrayInstPtr(arg)->f_element);
-                int nInstBytes;
-                OBJ cls;
+	} else if (typeSymbol == @symbol(floatPointer)) {
+	    thisType = __get_ffi_type_pointer();
+	    if (__isBytes(arg)) {
+		if (async == true) goto badArgForAsyncCall;
+		__argValues[i].pointerVal = (void *)(__byteArrayVal(arg));
+	    } else if (__isExternalAddressLike(arg)) {
+		__argValues[i].pointerVal = (void *)(__externalAddressVal(arg));
+	    } else if (__isExternalBytesLike(arg)) {
+		__argValues[i].pointerVal = (void *)(__externalBytesVal(arg));
+	    } else if (__isFloats(arg)) {
+		char *p = (char *)(__FloatArrayInstPtr(arg)->f_element);
+		int nInstBytes;
+		OBJ cls;
 
-                if (async == true) goto badArgForAsyncCall;
-                cls = __qClass(arg);
-                nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
-                p = p + nInstBytes;
-                __argValues[i].pointerVal = p;
-            } else {
-                if (arg == nil) {
-                    __argValues[i].pointerVal = (void *)0;
-                } else {
-                    __FAIL__(@symbol(InvalidArgument))
-                }
-            }
-            argValuePtr = &(__argValues[i].pointerVal);;
+		if (async == true) goto badArgForAsyncCall;
+		cls = __qClass(arg);
+		nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
+		p = p + nInstBytes;
+		__argValues[i].pointerVal = p;
+	    } else {
+		if (arg == nil) {
+		    __argValues[i].pointerVal = (void *)0;
+		} else {
+		    __FAIL__(@symbol(InvalidArgument))
+		}
+	    }
+	    argValuePtr = &(__argValues[i].pointerVal);;
 
-        } else if (typeSymbol == @symbol(doublePointer)) {
-            thisType = __get_ffi_type_pointer();
-            if (__isBytes(arg)) {
-                if (async == true) goto badArgForAsyncCall;
-                __argValues[i].pointerVal = (void *)(__byteArrayVal(arg));
-            } else if (__isExternalAddressLike(arg)) {
-                __argValues[i].pointerVal = (void *)(__externalAddressVal(arg));
-            } else if (__isExternalBytesLike(arg)) {
-                __argValues[i].pointerVal = (void *)(__externalBytesVal(arg));
-            } else if (__isDoubles(arg)) {
-                char *p = (char *)(__DoubleArrayInstPtr(arg)->d_element);
-                int nInstBytes;
-                OBJ cls;
+	} else if (typeSymbol == @symbol(doublePointer)) {
+	    thisType = __get_ffi_type_pointer();
+	    if (__isBytes(arg)) {
+		if (async == true) goto badArgForAsyncCall;
+		__argValues[i].pointerVal = (void *)(__byteArrayVal(arg));
+	    } else if (__isExternalAddressLike(arg)) {
+		__argValues[i].pointerVal = (void *)(__externalAddressVal(arg));
+	    } else if (__isExternalBytesLike(arg)) {
+		__argValues[i].pointerVal = (void *)(__externalBytesVal(arg));
+	    } else if (__isDoubles(arg)) {
+		char *p = (char *)(__DoubleArrayInstPtr(arg)->d_element);
+		int nInstBytes;
+		OBJ cls;
 
-                if (async == true) goto badArgForAsyncCall;
-                cls = __qClass(arg);
-                nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
-                p = p + nInstBytes;
+		if (async == true) goto badArgForAsyncCall;
+		cls = __qClass(arg);
+		nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
+		p = p + nInstBytes;
 # ifdef __NEED_DOUBLE_ALIGN
-                if ((INT)(__DoubleArrayInstPtr(arg)->d_element) & (__DOUBLE_ALIGN-1)) {
-                    int delta = __DOUBLE_ALIGN - ((INT)p & (__DOUBLE_ALIGN-1));
+		if ((INT)(__DoubleArrayInstPtr(arg)->d_element) & (__DOUBLE_ALIGN-1)) {
+		    int delta = __DOUBLE_ALIGN - ((INT)p & (__DOUBLE_ALIGN-1));
 
-                    p += delta;
-                }
+		    p += delta;
+		}
 # endif
-                __argValues[i].pointerVal = p;
-            } else {
-                if (arg == nil) {
-                    __argValues[i].pointerVal = (void *)0;
-                } else {
-                    __FAIL__(@symbol(InvalidArgument))
-                }
-            }
-            argValuePtr = &(__argValues[i].pointerVal);;
+		__argValues[i].pointerVal = p;
+	    } else {
+		if (arg == nil) {
+		    __argValues[i].pointerVal = (void *)0;
+		} else {
+		    __FAIL__(@symbol(InvalidArgument))
+		}
+	    }
+	    argValuePtr = &(__argValues[i].pointerVal);;
 
-        } else if (typeSymbol == @symbol(pointer)) {
+	} else if (typeSymbol == @symbol(pointer)) {
 commonPointerTypeArg: ;
-            thisType = __get_ffi_type_pointer();
-            if (arg == nil) {
-                __argValues[i].pointerVal = NULL;
-            } else if (__isExternalAddressLike(arg)) {
-                __argValues[i].pointerVal = (void *)(__externalAddressVal(arg));
-            } else if (__isExternalBytesLike(arg)) {
-                __argValues[i].pointerVal = (void *)(__externalBytesVal(arg));
-            } else if (__isByteArrayLike(arg)) {
-                if (async == true) goto badArgForAsyncCall;
-                __argValues[i].pointerVal = (void *)(__byteArrayVal(arg));
-            } else if (__isWordArray(arg) || __isSignedWordArray(arg)
-                    || __isIntegerArray(arg) || __isSignedIntegerArray(arg)) {
-                if (async == true) goto badArgForAsyncCall;
-                __argValues[i].pointerVal = (void *)(__integerArrayVal(arg));
-            } else if (__isFloatArray(arg)) {
-                if (async == true) goto badArgForAsyncCall;
-                __argValues[i].pointerVal = (void *)(__FloatArrayInstPtr(arg)->f_element);
-            } else if (__isDoubleArray(arg)) {
-                if (async == true) goto badArgForAsyncCall;
-                __argValues[i].pointerVal = (void *)(__DoubleArrayInstPtr(arg)->d_element);
-            } else if (__isStringLike(arg)) {
-                if (async == true) {
+	    thisType = __get_ffi_type_pointer();
+	    if (arg == nil) {
+		__argValues[i].pointerVal = NULL;
+	    } else if (__isExternalAddressLike(arg)) {
+		__argValues[i].pointerVal = (void *)(__externalAddressVal(arg));
+	    } else if (__isExternalBytesLike(arg)) {
+		__argValues[i].pointerVal = (void *)(__externalBytesVal(arg));
+	    } else if (__isByteArrayLike(arg)) {
+		if (async == true) goto badArgForAsyncCall;
+		__argValues[i].pointerVal = (void *)(__byteArrayVal(arg));
+	    } else if (__isWordArray(arg) || __isSignedWordArray(arg)
+		    || __isIntegerArray(arg) || __isSignedIntegerArray(arg)) {
+		if (async == true) goto badArgForAsyncCall;
+		__argValues[i].pointerVal = (void *)(__integerArrayVal(arg));
+	    } else if (__isFloatArray(arg)) {
+		if (async == true) goto badArgForAsyncCall;
+		__argValues[i].pointerVal = (void *)(__FloatArrayInstPtr(arg)->f_element);
+	    } else if (__isDoubleArray(arg)) {
+		if (async == true) goto badArgForAsyncCall;
+		__argValues[i].pointerVal = (void *)(__DoubleArrayInstPtr(arg)->d_element);
+	    } else if (__isStringLike(arg)) {
+		if (async == true) {
 badArgForAsyncCall: ;
-                    __FAIL__(@symbol(BadArgForAsyncCall))
-                }
-                __argValues[i].pointerVal = (void *)(__stringVal(arg));
-            } else if (__isBytes(arg) || __isWords(arg) || __isLongs(arg)) {
-                char *p = (char *)(__byteArrayVal(arg));
-                int nInstBytes;
-                OBJ cls;
+		    __FAIL__(@symbol(BadArgForAsyncCall))
+		}
+		__argValues[i].pointerVal = (void *)(__stringVal(arg));
+	    } else if (__isBytes(arg) || __isWords(arg) || __isLongs(arg)) {
+		char *p = (char *)(__byteArrayVal(arg));
+		int nInstBytes;
+		OBJ cls;
 
-                if (async == true) goto badArgForAsyncCall;
-                cls = __qClass(arg);
-                nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
-                __argValues[i].pointerVal = p + nInstBytes;
-            } else {
-                __FAIL__(@symbol(InvalidArgument))
-            }
-            argValuePtr = &(__argValues[i].pointerVal);;
+		if (async == true) goto badArgForAsyncCall;
+		cls = __qClass(arg);
+		nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
+		__argValues[i].pointerVal = p + nInstBytes;
+	    } else {
+		__FAIL__(@symbol(InvalidArgument))
+	    }
+	    argValuePtr = &(__argValues[i].pointerVal);;
 
-        } else if (typeSymbol == @symbol(bool)) {
-            thisType = __get_ffi_type_uint();
+	} else if (typeSymbol == @symbol(bool)) {
+	    thisType = __get_ffi_type_uint();
 
-            if (arg == true) {
-                __argValues[i].iVal = 1;
-            } else if (arg == false) {
-                __argValues[i].iVal = 0;
-            } else if (__isSmallInteger(arg)) {
-                __argValues[i].iVal = __intVal(arg);
-            } else {
-                __argValues[i].iVal = __unsignedLongIntVal(arg);
-                if (__argValues[i].iVal == 0) {
-                    __FAIL__(@symbol(InvalidArgument))
-                }
-            }
-            argValuePtr = &(__argValues[i].iVal);
-        } else {
-            if (__isSymbol(typeSymbol)
-             && ((argValueClass = __GLOBAL_GET(typeSymbol)) != nil)) {
-                if (! __isBehaviorLike(argValueClass)) {
-                    __FAIL__(@symbol(NonBehaviorArgumentType))
-                }
-                if (! __qIsSubclassOfExternalAddress(argValueClass)) {
-                    __FAIL__(@symbol(NonExternalAddressArgumentType))
-                }
-                goto commonPointerTypeArg; /* sorry */
-            } else {
-                __FAIL__(@symbol(UnknownArgumentType))
-            }
-        }
+	    if (arg == true) {
+		__argValues[i].iVal = 1;
+	    } else if (arg == false) {
+		__argValues[i].iVal = 0;
+	    } else if (__isSmallInteger(arg)) {
+		__argValues[i].iVal = __intVal(arg);
+	    } else {
+		__argValues[i].iVal = __unsignedLongIntVal(arg);
+		if (__argValues[i].iVal == 0) {
+		    __FAIL__(@symbol(InvalidArgument))
+		}
+	    }
+	    argValuePtr = &(__argValues[i].iVal);
+	} else {
+	    if (__isSymbol(typeSymbol)
+	     && ((argValueClass = __GLOBAL_GET(typeSymbol)) != nil)) {
+		if (! __isBehaviorLike(argValueClass)) {
+		    __FAIL__(@symbol(NonBehaviorArgumentType))
+		}
+		if (! __qIsSubclassOfExternalAddress(argValueClass)) {
+		    __FAIL__(@symbol(NonExternalAddressArgumentType))
+		}
+		goto commonPointerTypeArg; /* sorry */
+	    } else {
+		__FAIL__(@symbol(UnknownArgumentType))
+	    }
+	}
 
-        __argTypes[i] = thisType;
-        __argValuePointers[i] = argValuePtr;
+	__argTypes[i] = thisType;
+	__argValuePointers[i] = argValuePtr;
 
 # ifdef VERBOSE
-        printf("arg%d: %x\n", i, __argValues[i].iVal);
+	if (@global(Verbose) == true) {
+	    printf("arg%d: %"_lx_"\n", i, (INT)(__argValues[i].iVal));
+	}
 # endif
     }
     failureInfo = nil;
@@ -1494,97 +1505,134 @@
 
 # ifdef CALLTYPE_FFI_STDCALL
     if (callTypeNumber == @global(CALLTYPE_API)) {
-        __callType = CALLTYPE_FFI_STDCALL;
+	__callType = CALLTYPE_FFI_STDCALL;
     }
 # endif
 # ifdef CALLTYPE_FFI_V8
     if (callTypeNumber == @global(CALLTYPE_V8)) {
-        __callType = CALLTYPE_FFI_V8;
+	__callType = CALLTYPE_FFI_V8;
     }
 # endif
 # ifdef CALLTYPE_FFI_V9
     if (callTypeNumber == @global(CALLTYPE_V9)) {
-        __callType = CALLTYPE_FFI_V9;
+	__callType = CALLTYPE_FFI_V9;
     }
 # endif
 # ifdef CALLTYPE_FFI_UNIX64
     if (callTypeNumber == @global(CALLTYPE_UNIX64)) {
-        __callType = CALLTYPE_FFI_UNIX64;
+	__callType = CALLTYPE_FFI_UNIX64;
     }
 # endif
 
     if (ffi_prep_cif(&__cif, __callType, __numArgsIncludingThis, __returnType, __argTypesIncludingThis) != FFI_OK) {
-        __FAIL__(@symbol(FFIPrepareFailed))
+	__FAIL__(@symbol(FFIPrepareFailed))
     }
     if (async == true) {
 # ifdef VERBOSE
-        printf("async call 0x%x\n", codeAddress);
+	if (@global(Verbose) == true) {
+	    printf("async call 0x%"_lx_"\n", (INT)codeAddress);
+	}
 # endif
 # ifdef WIN32
-        __STX_C_CALL4( "ffi_call", ffi_call, &__cif, codeAddress, __returnValuePointer, __argValuePointersIncludingThis);
+	__STX_C_CALL4( "ffi_call", ffi_call, &__cif, codeAddress, __returnValuePointer, __argValuePointersIncludingThis);
 # else
-        __BEGIN_INTERRUPTABLE__
-        ffi_call(&__cif, codeAddress, __returnValuePointer, __argValuePointersIncludingThis);
-        __END_INTERRUPTABLE__
+	__BEGIN_INTERRUPTABLE__
+	ffi_call(&__cif, codeAddress, __returnValuePointer, __argValuePointersIncludingThis);
+	__END_INTERRUPTABLE__
 # endif
     } else {
-        if (unlimitedStack == true) {
+	if (unlimitedStack == true) {
 # ifdef VERBOSE
-            printf("UNLIMITEDSTACKCALL call 0x%x\n", codeAddress);
-# endif
-# if 0
-            __UNLIMITEDSTACKCALL__(ffi_call, &__cif, codeAddress, __returnValuePointer, __argValuePointersIncludingThis);
+	    if (@global(Verbose) == true) {
+		printf("UNLIMITEDSTACKCALL call 0x%"_lx_"\n", (INT)codeAddress);
+	    }
 # endif
-        } else {
+	    __UNLIMITEDSTACKCALL4__(ffi_call, &__cif, codeAddress, __returnValuePointer, __argValuePointersIncludingThis);
+	} else {
 # ifdef VERBOSE
-            printf("call 0x%x\n", codeAddress);
+	    if (@global(Verbose) == true) {
+		printf("call 0x%"_lx_"\n", (INT)codeAddress);
+	    }
 # endif
-            ffi_call(&__cif, codeAddress, __returnValuePointer, __argValuePointersIncludingThis);
-        }
+	    ffi_call(&__cif, codeAddress, __returnValuePointer, __argValuePointersIncludingThis);
+	}
     }
 # ifdef VERBOSE
-    printf("retval is %d (0x%x)\n", __returnValue.iVal, __returnValue.iVal);
+    if (@global(Verbose) == true) {
+	printf("retval is %"_ld_" (0x%"_lx_")\n", (INT)(__returnValue.iVal), (INT)(__returnValue.iVal));
+    }
 # endif
+
     if ((returnTypeSymbol == @symbol(int))
      || (returnTypeSymbol == @symbol(sint))
      || (returnTypeSymbol == @symbol(sint8))
      || (returnTypeSymbol == @symbol(sint16))
      || (returnTypeSymbol == @symbol(sint32))) {
-        RETURN ( __MKINT(__returnValue.iVal) );
+# ifdef VERBOSE
+	if (@global(Verbose) == true) {
+	    printf("return int: %x\n", __returnValue.iVal);
+	}
+# endif
+	RETURN ( __MKINT(__returnValue.iVal) );
     }
     if ((returnTypeSymbol == @symbol(uint))
      || (returnTypeSymbol == @symbol(uint8))
      || (returnTypeSymbol == @symbol(uint16))
      || (returnTypeSymbol == @symbol(uint32))) {
-        RETURN ( __MKUINT(__returnValue.iVal) );
+# ifdef VERBOSE
+	if (@global(Verbose) == true) {
+	    printf("return uint: %x\n", __returnValue.iVal);
+	}
+# endif
+	RETURN ( __MKUINT(__returnValue.iVal) );
     }
     if (returnTypeSymbol == @symbol(bool)) {
-        RETURN ( __returnValue.iVal ? true : false );
+	RETURN ( __returnValue.iVal ? true : false );
     }
     if (returnTypeSymbol == @symbol(float)) {
-        RETURN ( __MKFLOAT(__returnValue.fVal ));
+	RETURN ( __MKFLOAT(__returnValue.fVal ));
     }
     if (returnTypeSymbol == @symbol(double)) {
-        RETURN ( __MKFLOAT(__returnValue.dVal ));
+	RETURN ( __MKFLOAT(__returnValue.dVal ));
     }
     if (returnTypeSymbol == @symbol(void)) {
-        RETURN ( nil );
+	RETURN ( nil );
     }
     if (returnTypeSymbol == @symbol(char)) {
-        RETURN ( __MKCHARACTER(__returnValue.iVal & 0xFF) );
+	RETURN ( __MKCHARACTER(__returnValue.iVal & 0xFF) );
     }
     if (returnTypeSymbol == @symbol(wchar)) {
-        RETURN ( __MKUCHARACTER(__returnValue.iVal & 0xFFFF) );
+	RETURN ( __MKUCHARACTER(__returnValue.iVal & 0xFFFF) );
     }
     if (returnTypeSymbol == @symbol(sint64)) {
-        RETURN ( __MKINT64(&__returnValue.longLongVal) );
+# ifdef VERBOSE
+	if (@global(Verbose) == true) {
+	    printf("return sint64: %"_lx_"\n", (INT)(__returnValue.longLongVal));
+	}
+# endif
+# if __POINTER_SIZE__ == 8
+	RETURN ( __MKINT(__returnValue.longLongVal) );
+# else
+	RETURN ( __MKINT64(&__returnValue.longLongVal) );
+# endif
     }
     if (returnTypeSymbol == @symbol(uint64)) {
-        RETURN ( __MKUINT64(&__returnValue.longLongVal) );
+# ifdef VERBOSE
+	if (@global(Verbose) == true) {
+	    printf("return uint64: %"_lx_"\n", (unsigned INT)(__returnValue.longLongVal));
+	}
+# endif
+# if __POINTER_SIZE__ == 8
+	RETURN ( __MKUINT(__returnValue.longLongVal) );
+# else
+	RETURN ( __MKUINT64(&__returnValue.longLongVal) );
+# endif
     }
 
 # ifdef VERBOSE
-    printf("%x\n", __returnValue.pointerVal);
+    if (@global(Verbose) == true) {
+	printf("return pointer: %"_lx_"\n", (INT)(__returnValue.pointerVal));
+    }
 # endif
     if (returnTypeSymbol == @symbol(handle) || returnTypeSymbol == @symbol(pointer)) {
         if (__returnValue.pointerVal == NULL) {
@@ -1597,17 +1645,17 @@
                 (_initialize_ilc.ilc_func)(returnValue, @symbol(initialize), nil, &_initialize_ilc);
                 RETURN ( returnValue );
             } else {
-                returnValue = __MKEXTERNALADDRESS(__returnValue.pointerVal);
+	returnValue = __MKEXTERNALADDRESS(__returnValue.pointerVal);
             }
         }
     } else if (returnTypeSymbol == @symbol(bytePointer)) {
-        returnValue = __MKEXTERNALBYTES(__returnValue.pointerVal);
+	returnValue = __MKEXTERNALBYTES(__returnValue.pointerVal);
     } else if (returnTypeSymbol == @symbol(charPointer)) {
-        returnValue = __MKSTRING(__returnValue.pointerVal);
+	returnValue = __MKSTRING(__returnValue.pointerVal);
     } else if (returnTypeSymbol == @symbol(wcharPointer)) {
-        returnValue = __MKU16STRING(__returnValue.pointerVal);
+	returnValue = __MKU16STRING(__returnValue.pointerVal);
     } else {
-        __FAIL__(@symbol(UnknownReturnType2))
+	__FAIL__(@symbol(UnknownReturnType2))
     }
 #else /* no FFI support */
     failureCode = @symbol(FFINotSupported);
@@ -1615,48 +1663,48 @@
 getOutOfHere: ;
 %}.
     failureCode notNil ifTrue:[
-        (failureCode == #UnknownReturnType or:[ failureCode == #UnknownArgumentType ]) ifTrue:[
-            oldReturnType := returnType.
-            oldArgumentTypes := argumentTypes.
-            self adjustTypes.
-            ((oldReturnType ~= returnType) or:[oldArgumentTypes ~= argumentTypes]) ifTrue:[
-                thisContext restart
-            ].
-        ].
-        (failureCode == #BadArgForAsyncCall) ifTrue:[
-            ^ self tryAgainWithAsyncSafeArguments:argumentsOrNil forCPPInstance:aReceiverOrNil
-        ].
-        (failureCode == #FFINotSupported) ifTrue:[
-            self primitiveFailed:'FFI support missing in this build'.
-        ].
+	(failureCode == #UnknownReturnType or:[ failureCode == #UnknownArgumentType ]) ifTrue:[
+	    oldReturnType := returnType.
+	    oldArgumentTypes := argumentTypes.
+	    self adjustTypes.
+	    ((oldReturnType ~= returnType) or:[oldArgumentTypes ~= argumentTypes]) ifTrue:[
+		thisContext restart
+	    ].
+	].
+	(failureCode == #BadArgForAsyncCall) ifTrue:[
+	    ^ self tryAgainWithAsyncSafeArguments:argumentsOrNil forCPPInstance:aReceiverOrNil
+	].
+	(failureCode == #FFINotSupported) ifTrue:[
+	    self primitiveFailed:'FFI support missing in this build'.
+	].
 
-        self primitiveFailed.   "see failureCode and failureInfo for details"
-        ^ nil
+	self primitiveFailed.   "see failureCode and failureInfo for details"
+	^ nil
     ].
     returnType isSymbol ifTrue:[
-        returnValueClass notNil ifTrue:[
-            self isConstReturnValue ifTrue:[
-                returnValue changeClassTo:returnValueClass.
-                ^ returnValue
-            ].
-            ^ returnValueClass fromExternalAddress:returnValue.
-        ].
+	returnValueClass notNil ifTrue:[
+	    self isConstReturnValue ifTrue:[
+		returnValue changeClassTo:returnValueClass.
+		^ returnValue
+	    ].
+	    ^ returnValueClass fromExternalAddress:returnValue.
+	].
     ] ifFalse:[
-        returnType isCPointer ifTrue:[
-            returnType baseType isCStruct ifTrue:[
-                stClass := Smalltalk classNamed:returnType baseType name.
-                stClass notNil ifTrue:[
-                    self isConstReturnValue ifTrue:[
-                        returnValue changeClassTo:returnValueClass.
-                        ^ returnValue
-                    ].
-                    ^ stClass fromExternalAddress:returnValue.
-                ].
-            ].
-            returnType baseType isCChar ifTrue:[
-                ^ returnValue stringAt:1
-            ].
-        ].
+	returnType isCPointer ifTrue:[
+	    returnType baseType isCStruct ifTrue:[
+		stClass := Smalltalk classNamed:returnType baseType name.
+		stClass notNil ifTrue:[
+		    self isConstReturnValue ifTrue:[
+			returnValue changeClassTo:returnValueClass.
+			^ returnValue
+		    ].
+		    ^ stClass fromExternalAddress:returnValue.
+		].
+	    ].
+	    returnType baseType isCChar ifTrue:[
+		^ returnValue stringAt:1
+	    ].
+	].
     ].
 
     ^ returnValue
--- a/Float.st	Thu Mar 10 08:13:13 2016 +0000
+++ b/Float.st	Fri Mar 11 10:06:30 2016 +0000
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
 "
  COPYRIGHT (c) 1988 by Claus Gittinger
 	      All Rights Reserved
@@ -794,6 +796,11 @@
      by 53 binary digits (although only 52 are needed in the binary representation)"
 
     ^  53
+
+    "
+     self numBitsInMantissa + 1
+     self precision
+    "
 !
 
 radix
--- a/Integer.st	Thu Mar 10 08:13:13 2016 +0000
+++ b/Integer.st	Fri Mar 11 10:06:30 2016 +0000
@@ -1,5 +1,3 @@
-"{ Encoding: utf8 }"
-
 "
  COPYRIGHT (c) 1988 by Claus Gittinger
               All Rights Reserved
@@ -756,6 +754,8 @@
     "Modified: / 15.11.1999 / 20:35:20 / cg"
 ! !
 
+
+
 !Integer class methodsFor:'class initialization'!
 
 initialize
@@ -801,6 +801,7 @@
     "Modified: 18.7.1996 / 12:26:38 / cg"
 ! !
 
+
 !Integer class methodsFor:'prime numbers'!
 
 flushPrimeCache
@@ -1176,6 +1177,7 @@
     ^ self == Integer
 ! !
 
+
 !Integer methodsFor:'*Roe'!
 
 acceptRoeVisitor: aVisitor
@@ -2382,26 +2384,20 @@
 !
 
 digitByteLength
+    <resource: #obsolete>
     "return the number bytes required for a 2's complement
-     binary representation of this Integer.
-     For positive receivers, that's the same as the digitLength."
-
-    |absLen "{ Class: SmallInteger }" |
-
-    self >= 0 ifTrue:[^ self digitLength].
-
-    absLen := self negated digitLength.
-    (self digitByteAt:absLen) == 16rFF ifTrue:[
-        ^ (absLen - 1) max:1
-    ].
-    ^ absLen
-
-    "
+     binary representation of this Integer."
+
+    self obsoleteMethodWarning:'use signedDigitLength - attention: return value fixed'.
+    ^ self signedDigitLength
+
+    "
+     -127 digitByteLength
+     -128 digitByteLength
      -129 digitByteLength
-    "
-
-    "Created: / 25.10.1998 / 14:58:09 / cg"
-    "Modified: / 25.10.1998 / 19:20:33 / cg"
+     -32769 digitByteLength
+     32768 digitByteLength
+    "
 !
 
 digitBytes
@@ -2440,6 +2436,52 @@
     "
 !
 
+signedDigitLength
+    "return the number bytes required for a 2's complement
+     binary representation of this Integer.
+     I.e. the number of bytes from which we have to sign extent the highest bit"    
+
+    |absLen "{ Class: SmallInteger }" |
+
+    self >= 0 ifTrue:[
+        absLen := self digitLength.
+        (self digitByteAt:absLen) >= 16r80 ifTrue:[
+            ^ absLen + 1.
+        ].
+        ^ absLen.
+    ].
+
+    absLen := self negated digitLength.
+    (self digitByteAt:absLen) < 16r80 ifTrue:[
+            ^ absLen + 1
+    ].
+    ^ absLen
+
+    "
+     0 signedDigitLength
+     1 signedDigitLength
+     126 signedDigitLength
+     127 signedDigitLength
+     128 signedDigitLength
+
+     255 signedDigitLength
+     256 signedDigitLength
+     257 signedDigitLength
+
+     32767 signedDigitLength    
+     32768 signedDigitLength    
+
+     -1 signedDigitLength
+     -127 signedDigitLength
+     -128 signedDigitLength
+     -129 signedDigitLength
+
+     -32767 signedDigitLength    
+     -32768 signedDigitLength    
+     -32769 signedDigitLength    
+    "
+!
+
 swapBytes
     "swap bytes pair-wise in a positive integer
      i.e. a.b.c.d -> b.a.d.c
@@ -3443,7 +3485,7 @@
     ^ fibUsingDict value:self
 
     "the running time is mostly dictated by the LargeInteger multiplication performance...
-     (therefore, we get O(n²) execution times, even for a linear number of multiplications)
+     (therefore, we get O(n) execution times, even for a linear number of multiplications)
 
      Time millisecondsToRun:[50000 fib_iterative]  312    (DUO 1.7Ghz CPU)
      Time millisecondsToRun:[50000 fib_helper]     109
@@ -4452,10 +4494,10 @@
 !
 
 digitLength
-    "return the number of bytes needed for the binary representation
-     of the receiver.
-     This method is redefined in concrete classes - the fallback here is
-     never really used."
+    "return the number of bytes needed for the unsigned binary representation of the receiver.
+     For negative receivers, the result is not defined by the language standard.
+     This method is redefined in concrete classes 
+     - the fallback here is actually never used."
 
     ^ (self log:256) ceiling asInteger
 
@@ -4821,6 +4863,7 @@
     "Created: / 09-01-2012 / 17:18:06 / cg"
 ! !
 
+
 !Integer methodsFor:'special modulo arithmetic'!
 
 add_32:anInteger
--- a/LargeInteger.st	Thu Mar 10 08:13:13 2016 +0000
+++ b/LargeInteger.st	Fri Mar 11 10:06:30 2016 +0000
@@ -1,5 +1,3 @@
-"{ Encoding: utf8 }"
-
 "
  COPYRIGHT (c) 1994 by Claus Gittinger
 	      All Rights Reserved
@@ -1635,9 +1633,9 @@
 !
 
 digitLength
-    "return the number bytes used by this Integer.
-     For negative receivers, the digitLength of its absolute value
-     is returned."
+    "return the number of bytes needed for the unsigned binary representation of the receiver.
+     For negative receivers, the result is not defined by the language standard.
+     ST/X returns the digitLength of its absolute value."
 
     "
      check if there is a 0-byte ...
@@ -1653,7 +1651,7 @@
 %}.
     l := digitByteArray size.
     [l ~~ 0 and:[(digitByteArray at:l) == 0]] whileTrue:[
-	l := l - 1.
+        l := l - 1.
     ].
     ^ l
 
@@ -5692,3 +5690,4 @@
 version_CVS
     ^ '$Header$'
 ! !
+
--- a/LongFloat.st	Thu Mar 10 08:13:13 2016 +0000
+++ b/LongFloat.st	Fri Mar 11 10:06:30 2016 +0000
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
 "
  COPYRIGHT (c) 1999 by eXept Software AG
 	      All Rights Reserved
@@ -106,6 +108,13 @@
 #  include <string.h>
 # endif
 
+/*
+ * sigh: the default ming setup uses the micrsoft printf,
+ * which does not support long doubles
+ */
+
+# define snprintf  __mingw_snprintf
+
 #endif /* WIN32 */
 
 #ifdef solaris
@@ -141,6 +150,7 @@
 #  define LONG_log      logl
 #  define LONG_log10    log10l
 #  define LONG_modf     modfl
+#  define LONG_trunc    truncl
 #  define LONG_pow      powl
 #  ifdef __llvm__
 #   define LONG_isnan    isnan
@@ -181,10 +191,11 @@
 struct __longfloatstruct {
 	STX_OBJ_HEADER
 #ifdef __NEED_DOUBLE_ALIGN
-	__FILLTYPE_DOUBLE       f_filler;
+	__FILLTYPE_DOUBLE f_filler;
 #endif
-	LONGFLOAT               f_longfloatvalue;
+	LONGFLOAT f_longfloatvalue;
 };
+
 #define __LongFloatInstPtr(obj)      ((struct __longfloatstruct *)(__objPtr(obj)))
 
 #ifndef __longFloatVal
@@ -249,23 +260,26 @@
 	represented as 'doubles'.
 
     Representation:
-	gcc-x386:
+	gcc-x86:
 	    80bit extended IEEE floats stored in in 96bits (12bytes);
 	    64 bit mantissa,
 	    16 bit exponent,
-	    19 decimal digits (approx)
-
-	borland-i386 (WIN32):
+	    19 decimal digits (approx.)
+
+	borland-x86 (WIN32):
 	    80bit extended IEEE floats stored in in 80bits (10bytes);
 	    64 bit mantissa,
 	    16 bit exponent,
-	    19 decimal digits (approx)
+	    19 decimal digits (approx.)
+
+	gcc-x86_64: (WIN64)
+	    like gcc-x86
 
 	gcc-sparc:
 	    128bit quad IEEE floats (16bytes);
 	    112 bit mantissa,
 	    16 bit exponent,
-	    34 decimal digits (approx)
+	    34 decimal digits (approx.)
 
     Mixed mode arithmetic:
 	longFloat op longFloat   -> longFloat
@@ -676,19 +690,12 @@
     self error:'missing definition'  "ifdef missing in above primitive code for this architecture"
 
     "
+     1.0 class numBitsInMantissa
+     1.0 asShortFloat class numBitsInMantissa
      1.0 asLongFloat class numBitsInMantissa
     "
 !
 
-precision
-    "answer the precision of a LongFloat (in bits)
-     This is an IEEE float, where only the fraction from the normalized mantissa is stored
-     and so there is a hidden bit and the mantissa is actually represented by 64 binary digits
-     (although only 63 are needed in the binary representation)"
-
-    ^ 64
-!
-
 radix
    "answer the radix of a LongFloats exponent
     This is an IEEE float, which is represented as binary"
@@ -1613,6 +1620,10 @@
 	1e10 asLongFloat printString.
 	1.2e3 asLongFloat printString.
 	1.2e30 asLongFloat printString.
+	(1.0 uncheckedDivide:0)  isInfinite.
+	(0.0 uncheckedDivide:0)  isNaN.
+	(1.0 uncheckedDivide:0) asLongFloat isInfinite.
+	(0.0 uncheckedDivide:0) asLongFloat isNaN.
 	(1.0 uncheckedDivide:0) asLongFloat printString.
 	(0.0 uncheckedDivide:0) asLongFloat printString.
 	self pi printString.
@@ -2688,7 +2699,17 @@
     LONGFLOAT frac, trunc;
     OBJ v;
 
+    // mingw64 runtime modfl has a bug, triggering a SEGV
+    // see https://sourceforge.net/p/mingw-w64/bugs/478/
+# if defined(MINGW_MODFL_BUG)
+    {
+	LONGFLOAT value = __longFloatVal(self);
+	LONGFLOAT int_part = LONG_trunc(value);
+	frac = (isinf (value) ?  0.0L : value - int_part);
+    }
+# else
     frac = LONG_modf(__longFloatVal(self), &trunc);
+# endif
     __qMKLFLOAT(v, frac);
     RETURN (v);
 #endif
--- a/ShortFloat.st	Thu Mar 10 08:13:13 2016 +0000
+++ b/ShortFloat.st	Fri Mar 11 10:06:30 2016 +0000
@@ -564,6 +564,11 @@
      (although only 23 are needed in the binary representation)"
 
     ^  24
+
+    "
+     self numBitsInMantissa + 1
+     self precision
+    "
 !
 
 radix
--- a/SmallInteger.st	Thu Mar 10 08:13:13 2016 +0000
+++ b/SmallInteger.st	Fri Mar 11 10:06:30 2016 +0000
@@ -45,8 +45,9 @@
 documentation
 "
     SmallIntegers are Integers in the range of at least +/- 2^30
-    (i.e. 31 bits, which is not a guaranteed: on an alpha, 63 bits are used,
-     if the system was configured for 64bit mode).
+    i.e. 31 bits, but this is not a guaranteed:
+        on an alpha or x86_64, 63 bits are used, if the system was configured for 64bit mode.
+        under the Schteam-VM, 64 bits are used (i.e. a full long integer)
 
     These are no real objects - they have no instances (not even storage !!)
     and cannot be subclassed.
@@ -61,12 +62,12 @@
     with an instance variable holding the value.
 
     [author:]
-	Claus Gittinger
+        Claus Gittinger
 
     [see also:]
-	Number
-	Float Fraction FixedPoint
-	LargeInteger
+        Number
+        Float Fraction FixedPoint
+        LargeInteger
 "
 ! !
 
@@ -1401,9 +1402,9 @@
     "return the value of the receiver shifted by shiftCount bits;
      leftShift if shiftCount > 0; rightShift otherwise.
      Notice: the result of bitShift: on negative receivers is not
-	     defined in the language standard (since the implementation
-	     is free to choose any internal representation for integers).
-	     However, ST/X preserves the sign."
+             defined in the language standard (since the implementation
+             is free to choose any internal representation for integers).
+             However, ST/X preserves the sign."
 
 %{  /* NOCONTEXT */
 #ifdef __SCHTEAM__
@@ -1412,68 +1413,80 @@
     INT bits, count;
 
     if (__isSmallInteger(shiftCount)) {
-	bits = __intVal(self);
-	if (bits == 0) {
-	    RETURN (self);
-	}
-
-	count = __intVal(shiftCount);
-
-	if (count > 0) {
-	    /*
-	     * a left shift
-	     */
+        bits = __intVal(self);
+        if (bits == 0) {
+            RETURN (self);
+        }
+        count = __intVal(shiftCount);
+
+        if (count > 0) {
+            INT sign = 1;
+            if (bits < 0) {
+                bits = -bits;
+                sign = -1;
+            }
+            /*
+             * a left shift
+             */
 # if defined(USE_LONGLONG_FOR_SHIFT)
-	    if (count <= N_INT_BITS) {
-		unsigned LONGLONG result;
-
-		result = (unsigned LONGLONG)bits;
-		result <<= count;
-		if (result <= _MAX_INT) {
-		    RETURN ( __mkSmallInteger(result) );
-		}
-		{
-		    RETURN (__MKLARGEINT64(1, (INT)(result >> 32), (INT)(result & 0xFFFFFFFF)));
-		}
-	    }
+            if (count <= N_INT_BITS) {
+                unsigned LONGLONG result;
+
+                result = (unsigned LONGLONG)bits;
+                result <<= count;
+                if (result <= _MAX_INT) {
+                    if (sign < 0) {
+                        RETURN ( __MKINT(-result) );
+                    }
+                    RETURN ( __mkSmallInteger(result) );
+                }
+                {
+                    RETURN (__MKLARGEINT64(sign, (INT)(result >> 32), (INT)(result & 0xFFFFFFFF)));
+                }
+            }
 # else
-	    /*
-	     * check for overflow
-	     */
-	    if (count < (N_INT_BITS-1)) {
-		if (! (bits >> (N_INT_BITS - 1 - count))) {
-		    RETURN ( __mkSmallInteger(bits << count) );
-		}
-		/*
-		 * so, there is an overflow ...
-		 * handle it as largeInteger
-		 */
-		/* FALL THROUGH */
-	    }
+            /*
+             * check for overflow
+             */
+            if (count < (N_INT_BITS-1)) {
+                if (! (bits >> (N_INT_BITS - 1 - count))) {
+                    INT result = bits << count;
+                    
+                    if (sign < 0) {
+                        RETURN ( __MKINT(-result) );
+                    }
+                    RETURN ( __mkSmallInteger(result) );
+                }
+                /*
+                 * so, there is an overflow ...
+                 * handle it as largeInteger
+                 */
+                /* FALL THROUGH */
+            }
 # endif
-	} else {
-	    if (count == 0) {
-		RETURN (self);
-	    }
-
-	    /*
-	     * right shifts cannot overflow
-	     *
-	     * some machines ignore shifts bigger than
-	     * the number of bits in an int ...
-	     */
-	    count = -count;
-	    if (count > (N_INT_BITS-1)) {
-		RETURN (__mkSmallInteger(0));
-	    }
-
-	    RETURN ( __mkSmallInteger(bits >> count) );
-	}
+        } else {
+            if (count == 0) {
+                RETURN (self);
+            }
+
+            /*
+             * right shifts cannot overflow
+             *
+             * some machines ignore shifts bigger than
+             * the number of bits in an int ...
+             */
+            count = -count;
+            if (count > (N_INT_BITS-1)) {
+                RETURN (__mkSmallInteger(0));
+            }
+
+            RETURN ( __mkSmallInteger(bits >> count) );
+        }
     }
 #endif /* not __SCHTEAM__ */
 %}.
     (shiftCount isMemberOf:SmallInteger) ifTrue:[
-	^ (LargeInteger value:self) bitShift:shiftCount
+        ^ (LargeInteger value:self) bitShift:shiftCount
     ].
     ^ self bitShift:shiftCount asInteger   "/ is this a good idea ?
 !
@@ -2595,9 +2608,9 @@
 !
 
 digitLength
-    "return the number bytes required to represent this Integer.
-     For negative receivers, the digitLength of its absolute value
-     is returned."
+    "return the number of bytes needed for the unsigned binary representation of the receiver.
+     For negative receivers, the result is not defined by the language standard.
+     ST/X returns the digitLength of its absolute value."
 
 %{  /* NOCONTEXT */
 #ifdef __SCHTEAM__
@@ -2606,21 +2619,21 @@
 
     if (val < 0) val = -val;
     if ((val & 0xFFFFFFFF00000000L) != 0) {
-	val >>= 32;
-	offs = 4;
+        val >>= 32;
+        offs = 4;
     }
     if ((val & 0xFFFF0000) != 0) {
-	if ((val & 0xFF000000) != 0) {
-	    offs += 4;
-	} else {
-	    offs += 3;
-	}
+        if ((val & 0xFF000000) != 0) {
+            offs += 4;
+        } else {
+            offs += 3;
+        }
     } else {
-	if ((val & 0x0000FF00)!= 0) {
-	    offs += 2;
-	} else {
-	    offs += 1;
-	}
+        if ((val & 0x0000FF00)!= 0) {
+            offs += 2;
+        } else {
+            offs += 1;
+        }
     }
     return __c__._RETURN( STInteger._qnew(offs) );
 #else
@@ -2628,27 +2641,27 @@
     int offs = 0;
 
     if (val < 0) {
-	val = -val;
+        val = -val;
     }
 # if __POINTER_SIZE__ == 8
     if (val & 0xFFFFFFFF00000000L) {
-	val >>= 32;
-	offs = 4;
+        val >>= 32;
+        offs = 4;
     }
 # endif
 
     if (val & 0xFFFF0000) {
-	if (val & 0xFF000000) {
-	    RETURN ( __mkSmallInteger(4+offs));
-	} else {
-	    RETURN ( __mkSmallInteger(3+offs));
-	}
+        if (val & 0xFF000000) {
+            RETURN ( __mkSmallInteger(4+offs));
+        } else {
+            RETURN ( __mkSmallInteger(3+offs));
+        }
     } else {
-	if (val & 0x0000FF00) {
-	    RETURN ( __mkSmallInteger(2+offs));
-	} else {
-	    RETURN ( __mkSmallInteger(1+offs));
-	}
+        if (val & 0x0000FF00) {
+            RETURN ( __mkSmallInteger(2+offs));
+        } else {
+            RETURN ( __mkSmallInteger(1+offs));
+        }
     }
 #endif /* not SCHTEAM */
 %}.